x/tools/go/ssa: race condition between generic instantiations in separate packages #63247
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, this is the latest release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Check out the code here: https://github.com/aykevl/sandbox/tree/main/ssa-generics-race
Now build this with the race condition checker enabled, and run it a number of times (the race only manifests itself sometimes). In the fish shell, that looks like this:
What did you expect to see?
It should not trigger a race condition.
What did you see instead?
The high-level overview of the code is as follows:
value.New[int]
function that was built as part of testb.My guess would be that there is a shared cache of instantiated generic functions, and while the testa package has started building the
value.New[int]
function and added it to the cache, testb will just use it without waiting for it to be finished building.It is possible there is some invariant I have violated in my code, but if I have, I'm not sure what that would be. While building dependencies of packages first seems reasonable, I don't see why sibling packages would need to wait until the other is finished before accessing instantiated generic functions.
The text was updated successfully, but these errors were encountered: