-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/tools/go/ssa: function.Origin() panics with "index out of range" #59427
Comments
CC @golang/tools-team |
IIUC the key issue seems to be that in the test, the following happens:
This can be resolved by making sure the "value" package is built before asking for the Origin. Or by building the ssa.Program. I think my question is what are you hoping for the "sensible" output to be? Are you hoping to get nil as the result? Are you hoping for the "value" package to get built if you happened to request this? A more user friendly panic message? FWIW are you sure you do not want to build
I'll be happy to take a look once you have more info. |
Thank you for investigating!
I am not entirely sure. At the very least, a more useful panic message would go a long way. Also, documentation that says how this case should be handled would be helpful, something like "
Hmm, perhaps I need to do this. I think the last time I tried this I ran into some issues, but I can try again. What I really want is to get the AST node from which the generic function was built. Unfortunately,
I'm pretty sure this is a related bug, as I build the programs in parallel (which means that one |
Change https://go.dev/cl/491735 mentions this issue: |
Change https://go.dev/cl/491755 mentions this issue: |
Building the dependencies first indeed appears to fix the problem. It does complicate the build a little bit though. |
Keep the Syntax() for function instantiations when the origin package has debug info enabled. Updates golang/go#59427 Change-Id: I0a2a6ad2abbcec8226ef044510926dae33a2471a Reviewed-on: https://go-review.googlesource.com/c/tools/+/491735 Run-TryBot: Tim King <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Zvonimir Pavlinovic <[email protected]>
I have finally managed to make a reproducer for this race condition, and made a bug report here: #63247 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, 1.20.2 is the latest release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
To reproduce:
go run .
What did you expect to see?
I expected
.Origin()
(last line of the program) to return something sensible.What did you see instead?
It panics. Here is the complete output of the program, including all debug prints:
Note: I have also found a race condition when working with two SSA packages in a sing
le
*ssa.Program
that contains generics, but haven't been able to create a solid reproducer yet. I do feel like this bug could be related to that race condition.Original issue found in tinygo-org/tinygo#3593.
The text was updated successfully, but these errors were encountered: