-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: main_init_done can race with cgocall, yielding partially initialized (user) packages #68479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Null-dereference is here [1] because its initialization [2] didn't execute. Based on my vague understanding of what's happening, it appears we have a race between a previous
and the above NOTE: the fuzz target is generated using [1] https://github.com/cockroachdb/cockroach/blob/bcd4e5e37f2a95e73347f5ed83db5a24bebfd8d1/pkg/keys/printer.go#L599 |
This seems to be a variant of #15943 |
Not exactly. I did look at the issue before creating this one. They're definitely related, but the race described here seems to be unique, afaik. |
Hmm, isn't it the same problem: c thread calling to Go without knowing that all init functions are done? |
The receiving on |
@cherrymui That is a good point. I don't see how this scenario could happen. @srosenberg How can we recreate the problem? Note that the link to oss-fuzz.com in the initial post doesn't work--it just says "You (email=[email protected]) are not authorized to access this page!". |
Apologies, false alarm! After further debugging, The actual problem turned out to be a failed dependency injection in our code. The simple reason [1] Line 437 in 70491a8
[2] https://github.com/cockroachdb/cockroach/blob/bcd4e5e37f2a95e73347f5ed83db5a24bebfd8d1/pkg/ts/keys.go#L130 [3] https://github.com/cockroachdb/cockroach/blob/8def76b7b83df90d7e2bdf07309d61da8bfcf1d3/pkg/keys/printer.go#L848 |
Go version
go version go1.22.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
A fuzz target (
fuzzEngineKeys
), written in Go, and integrated with OSS-Fuzz as per the instructions in [1], resulted in a null-dereference owing to the fact that the enclosing package had not finished initializing at the time of the C->Go call.[1] https://google.github.io/oss-fuzz/getting-started/new-project-guide/go-lang/
What did you see happen?
Below is the stacktrace, easily reproducible from [1].
[1] https://oss-fuzz.com/testcase-detail/5128848228810752
What did you expect to see?
We expect all packages to be fully initialized before any user function is invoked. It's an invariant according to the language spec. [1].
[1] https://go.dev/ref/spec#Package_initialization
The text was updated successfully, but these errors were encountered: