Repository navigation
[AUTOMATED] Demote go.typedesc interface type-word parameters to the honest opaque type - #1543
Merged
Merged
Conversation
A Go interface value is a (type, data) pair, and a &type:T descriptor global (the type word) passed to any-taking runtime/stdlib functions (runtime.gopanic(e any), fmt.(*pp).printArg, encoding/binary.Read, sync/atomic.(*Value).Store, encoding/json.MarshalIndent) was committed onto the callee's parameter as go.typedesc * -- a wrong concrete whole-binary signature where the truth is a bare word. Two paths deliver it: local type inference inside the callee, and the callee-vote plane. A go.typedesc is the synthesized internal/abi.Type base shell, never a value type anything is declared as, so it is provably never a real parameter type. FuncProto::updateInputTypes demotes a recovered go.typedesc * parameter to the honest untyped word of the same width, and the callee-vote plane refuses to monomorphize a parameter to it. The body keeps its local descriptor typing where it genuinely reads the word as a type; only the declaration is corrected. The genuine runtime type abi.Type, which reflect/runtime functions legitimately take by pointer, and real concrete-pointer params (syscall.Fstat(syscall.Stat_t *), big.Int receivers) are untouched. vet corpus: 18 functions declared a go.typedesc * parameter, every one the interface-word mislabel, all demoted; zero genuine signatures changed, 2285 feature effects retained. Strict bugfix (no option/count change); inert off-Go. Regression test green under go1.22/1.25/1.27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The Go type-descriptor globals (#1540) and allocation typing (#1542) correctly name concrete types at allocation sites, but that concrete
go.typedesc *type then propagated onto the interface type-word of sharedany/interface{}parameters, mislabeling generic functions with a caller's specific type:The fix:
go.typedescis a synthesized descriptor shell — the harvester only ever names data globals with it, never a value or parameter. So a recoveredgo.typedesc *parameter is provably a mislabeled interface type-word, andFuncProto::updateInputTypesdemotes it to a same-width opaque word (input_voterefuses it too). The real runtime type genuine descriptor-taking functions use —abi.Type— is a different interned type and is untouched.Verified by independent adversarial review on
vet.stripped(5,720 functions, three toolchains): 23 signatures change — 18 intendedgo.typedesc *demotions (gopanic,printany,atomic.(*Value).Store, …) plus 5 benign[]any-pointer vague→vague cascades (fmt.Fprint/Sprint/doPrint,log.Fatal,go/build.importGo— no store/call/computation dropped). The genuine descriptor-pointer functions (getitab,reflect.New,typeAssertwithabi.Type *) and concrete data-word params (main.Shape *beside a demoted type-word inatomic.Value.Store) are byte-identical off/on;/bin/tarbyte-identical.Strict bugfix — no option or count change, inert off-Go. Closes 18 of the 19 descriptor-leak signatures; the remaining non-
go.typedescconcrete leak (json.Unmarshal(Config *)) needs cross-caller conflict detection and is a scoped follow-up.Test:
verify_gotypes::no_function_declares_a_go_typedesc_parameter, green under go1.22/1.25/1.27. Datatests 675/675 and stages unchanged.🤖 Generated with Claude Code