Repository navigation
[AUTOMATED] Pin the goroutine g register as a typed global (option goreg, default on with the golang spec) - #1276
Merged
Merged
Conversation
… goreg, default on) Under the Go register ABI the current goroutine lives in a pinned register (R14 on amd64, x28 on arm64 - the vendored golang register.info values); the cspec lists it unaffected and no pentry names it, so every access rendered as a phantom local (v3; // r14) fed by unexplained arithmetic. With the golang cspec active (goabi), the register's storage now joins the global scope (the cspec <global><register/> mechanism applied kuna-side; the vendored spec stays pristine) and a type+name-locked `g` symbol typed runtime.g * maps over it. runtime.g / runtime.gobuf are synthesized shells carrying exactly the fields the go1.22 runtime source states for the register-ABI era (liblink prefix stable across releases; tail go1.22-pinned; past-prefix accesses stay anchored as offsets off g). Load-time env bridge KUNA_GOREG (the goabi seam); structurally inert off-Go; a golang target with no pinned register (x86-32, TLS) is untouched. Measured on the stripped go1.22 hello-world (1,543 fns): phantom // r14 functions 267 -> 23, named g-> field readers 7 -> 297, runtime.unlock2 renders g->stackguard0 = 0xfffffffffffffade exactly as the runtime source spells the preemption request. Speed: interleaved min-of-3 decompile-all on the witness 18.79 s on vs 18.59 s off (+1.1%, a load-time symbol install; budget 5%). Gates: make test PARITY OK, make test-stages PARITY OK (baseline re-record: the renamed catalog #15), make rust-test exit 0 (clean), make check-spec OK, make test-cli 306/306, make lint clean, kuna catalog --check OK. E2E verify_goreg (own [[test]]: the off arm mutates env) builds a real stripped go binary and pins both directions; unit tests pin the shell offsets against the runtime source and the golang-id gate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WoTv7T2Ep5hmbZcyYSMk1g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the golang cspec selected, the goroutine register still rendered as a phantom local in a quarter of all functions — declared, read, never assigned:
The fix:
R14, arm64x28— both stated by the vendoredregister.info; x86-32 golang is TLS-based and correctly gets none) joins the global scope exactly the way a cspec<global><register/>entry would, with a type- and name-lockedgsymbol — the vendored specs stay pristine.runtime.gandruntime.gobufshell types are synthesized with only source-verified fields: the liblink-stated release-stable prefix (stackguard0,_panic,m), thegobufat 0x38, and the go1.22-pinned tail throughgoid; accesses past the shell render as anchored offsets offgrather than phantom arithmetic.goreg on|off, default on; inert without the golang spec by construction (it requiresgoabi's selection).Measured on a stripped go1.22 build (1,543 functions): functions declaring a phantom
// r14local 267 → 23; functions reading namedg->fields 7 → 297; wall +1.1% (budget 5%), inert off-Go.Tests:
verify_gorege2e over a real stripped build pins both directions onruntime.unlock2; hermetic unit tests pin the shell offsets against the runtime source and the golang-id gate. Datatests 675/675 unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_01WoTv7T2Ep5hmbZcyYSMk1g