-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: mysterious crashes and non-determinism with range over func #69507
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
Thanks for the report and reproducer! This looks like some sort of memory corruption of the map. My initial thought is to wonder if the map is stack allocated and the coroutine handling is corrupting the stack/use-after-free. cc @golang/runtime @dr2chase |
Possibly related to #69434 |
This looks like an escape analysis bug? |
@gopherbot Please open a backport to 1.23. This appears to be a compiler bug related to the range-over-function code. The compiler is generating bad code--a variable that escapes is stack-allocated. There is no workaround (other than avoiding range-over-func). |
Backport issue(s) opened: #69511 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/614096 mentions this issue: |
Go version
go version go1.23.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I tried to use the new range over func loops. Here is the code:
https://go.dev/play/p/rYiGIM4RaVe
This is a pared down version of a much longer program. The code here does no longer make much sense, but has no external dependencies and still shows the problem.
What did you see happen?
There are several problems with this code:
fatal error: concurrent map read and map write
. Note that there is no explicit concurrency in this code. The crash goes away if the print statement on line 80 is enabled.bestM
.What did you expect to see?
The code should not crash, and the absence/presence of the print statement should not change the behaviour of the program.
The text was updated successfully, but these errors were encountered: