-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: fatal error: reflect mismatch when reflect.MakeFunc is used as a goroutine #25897
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
Works in Go 1.3, fails in every version since. Works with gccgo. Easy to work around. Setting milestone to 1.12. |
Kindly paging also @randall77 |
The easy, shallow fix for this is probably to teach the compiler to do the “wrap in a closure” trick itself. It already does that for a print and some other builtins; this probably just requires adding a special case for (say) any calls in package reflect. Might be a decent starter issue for someone working on the compiler. |
It looks like the problem is scanning a goroutine where the top level function is Here's a simpler repro:
run with
@josharian I don't think the wrapper strategy will work. At the point of the |
Change https://golang.org/cl/180258 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.3 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I have a function
consume()
made byreflect.MakeFunc()
. When I run it as a goroutinego consume(...)
, if it coincides with a GC cycle, the program dies with the following error:Each time the fatal error happens, the goroutine with
runnable (scan)
status is always inreflect.makeFuncStub()
. However, if I wrap the goroutine under a func() closure likego func() { consume(...) }()
then the problem goes away.Here is a playground link showing that this issue is reproducible in the playground: https://play.golang.org/p/vDyOEMZoAWf
There is a previous issue also mentioning reflect mismatch, but I think that's a different issue that is already fixed: #18635
What did you expect to see?
The program should run until completion.
What did you see instead?
The program crashed with "fatal error: reflect mismatch"
The text was updated successfully, but these errors were encountered: