-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: go1.11.5 GC crash when calling reflect.MakeFunc function #30041
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
Sounds like #28750 also, but that should have been fixed in 1.11.4. |
https://go.googlesource.com/go/+/go1.11.5/src/reflect/value.go#567 If I understand correctly, this stores to the stack, which is uninitialized at this point, but has a write barrier. But even I disable this write barrier, the program can still crash. I no longer see the crash with bad pointer found in write barrier buffer flush, but still see bad pointer found in gcDrain. There must be some other problem... |
Apparently my local change didn't take effect in the first time. I think by removing that write barrier it indeed fix the problem. |
Change https://golang.org/cl/160737 mentions this issue: |
We are copying the results to uninitialized stack space. Write barrier is not needed. TODO: add a test. I don't know how to test this in a reliable way. Fixes golang#30041. Change-Id: Ia91d74dbafd96dc2bd92de0cb479808991dda03e
Thanks, I did some local testing and it no longer reproduces the crash. I've applied the patch to our toolchain and going to do some more testing on the real code. |
We are copying the results to uninitialized stack space. Write barrier is not needed. Fixes golang#30041. Change-Id: Ia91d74dbafd96dc2bd92de0cb479808991dda03e Reviewed-on: https://go-review.googlesource.com/c/160737 Run-TryBot: Cherry Zhang <[email protected]> Reviewed-by: Keith Randall <[email protected]>
We are copying the results to uninitialized stack space. Write barrier is not needed. Fixes golang#30041. Change-Id: Ia91d74dbafd96dc2bd92de0cb479808991dda03e Reviewed-on: https://go-review.googlesource.com/c/160737 Run-TryBot: Cherry Zhang <[email protected]> Reviewed-by: Keith Randall <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go run main.go
from this example https://gist.github.com/mgood/2f92cbfa67bfb15fef5b59617a466d30What did you expect to see?
Should keep running until stopped
What did you see instead?
In production we also saw other runtime crashes such as:
This seems similar to #18635 which was fixed in Go 1.8rc2, however the example in that issue keeps running for me until it hits the stack depth limit.
When running with
-race
no errors are reported, but it also doesn't reproduce the crash so the race detector may be imposing some synchronization that mitigates the problem.The body of the loop in
GetSomeFlag
doesn't contain any concurrency or modify any external state, so our suspicion is that the issue is related toreflect.MakeFunc
since that's the only part that seems unusual. If I replace thereflect
func with a regular func I haven't been able to reproduce the crash.The text was updated successfully, but these errors were encountered: