-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: panic: runtime error: invalid memory address or nil pointer dereference [dev.regabi] #43701
Comments
git bisect points to https://go-review.googlesource.com/c/go/+/281352 |
Thanks. I'm guessing the test case tickles some mismatch between the logic in gc.prepareFunc for deciding whether to create the stkobj symbol, and the code in ssagen.emitStackObjects. I wonder if we can just move that code from gc.prepareFunc to ssagen.emitStackObjects? The comments say that code isn't safe to run during SSA generation, but I don't think that's true anymore. At least looking at them briefly, I see mutexes being used. I'd recommend trying to relocate the code and see if it passes the racecompile trybot. It would also be interesting to know what variables are being caught by ssagen.emitStackObjects but missed by gc.prepareFunc. Not because it's necessary for the fix per se, but to double-check that we understand the failure. @cuonglm Do you want to look into fixing this? |
@mdempsky I did some investigation already, the problem is after CL 281352, the closure var I will be AFK for couple of hours, I can try a fix when I'm back. |
@cuonglm Thanks. No rush on the fix if you're interested in it. Hm, I can believe that's the issue, but I'm not immediately seeing how it led to this issue. Do you mind getting the output from Sorry for asking so much. Also, if simply moving the sym generation to emitStackObjects fixes the issue and passes the racecompile slowbot, I think it's reasonable to go ahead and commit that while we continue understanding why it failed in the first place. |
Oh, and finally: are we crashing trying to write out stack objects for |
@ALTree Thanks for the issue report and the reproducer. I'm assuming that's minimized down from some real world code? If so, are you able to share that? (Not important, just curious.) |
it's |
Oh, that's surprising. I didn't expect |
Change https://golang.org/cl/284112 mentions this issue: |
@mdempsky Sorry, there's no real world code; the crasher was found by a fuzzer. |
@ALTree No apology needed. I'd rather a fuzzer discover compiler issues than an end user. :) |
Change https://golang.org/cl/284075 mentions this issue: |
Change https://golang.org/cl/284076 mentions this issue: |
Change https://golang.org/cl/284077 mentions this issue: |
We decide during escape analysis whether to pass closure variables by value or reference. One of the factors that's considered is whether a variable has had its address taken. However, this analysis is based only on the user-written source code, whereas order+walk may introduce rewrites that take the address of a variable (e.g., passing a uint16 key by reference to the size-generic map runtime builtins). Typically this would be harmless, albeit suboptimal. But in #43701 it manifested as needing a stack object for a function where we didn't realize we needed one up front when we generate symbols. Probably we should just generate symbols on demand, now that those routines are all concurrent-safe, but this is a first fix. Thanks to Alberto Donizetti for reporting the issue, and Cuong Manh Le for initial investigation. Fixes #43701. Change-Id: I16d87e9150723dcb16de7b43f2a8f3cd807a9437 Reviewed-on: https://go-review.googlesource.com/c/go/+/284075 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
The code for allocating linksyms and recording that we need runtime type descriptors is now concurrent-safe, so move it to where those symbols are actually needed to reduce complexity and risk of failing to generate all needed symbols in advance. For #43701. Change-Id: I759d2508213ac9a4e0b504b51a75fa10dfa37a8d Reviewed-on: https://go-review.googlesource.com/c/go/+/284076 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
WriteType isn't safe for direct concurrent use, and users should instead use TypeLinksym or another higher-level API provided by reflectdata. After the previous CL, there are no remaining uses of WriteType elsewhere in the compiler, so unexport it to keep it that way. For #43701. [git-generate] cd src/cmd/compile/internal/reflectdata rf ' mv WriteType writeType ' Change-Id: I294a78be570a47feb38a1ad4eaae7723653d5991 Reviewed-on: https://go-review.googlesource.com/c/go/+/284077 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
dev.regabi branch
cc @mdempsky @cuonglm
The text was updated successfully, but these errors were encountered: