-
Notifications
You must be signed in to change notification settings - Fork 18k
gccgo: seg fault if profiling signal arrives when collecting backtrace #29448
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
Change https://golang.org/cl/156037 mentions this issue: |
Change https://golang.org/cl/156038 mentions this issue: |
Change https://golang.org/cl/156018 mentions this issue: |
Traceback routines, e.g. callers and funcentry, may call __go_get_backtrace_state. If a profiling signal arrives while we are in the critical section of __go_get_backtrace_state, it tries to do a traceback, which also calls __go_get_backtrace_state, which tries to enter the same critical section and will deadlock. Prevent this deadlock by setting up runtime_in_callers before calling __go_get_backtrace_state. Found while investigating golang/go#29448. Will add a test in the next CL. Updates golang/go#29448. Change-Id: Ifb50c50aedc6faf7259757b82e11b30b867bc70d Reviewed-on: https://go-review.googlesource.com/c/156037 Reviewed-by: Ian Lance Taylor <[email protected]>
…back Traceback routines, e.g. callers and funcentry, may call __go_get_backtrace_state. If a profiling signal arrives while we are in the critical section of __go_get_backtrace_state, it tries to do a traceback, which also calls __go_get_backtrace_state, which tries to enter the same critical section and will deadlock. Prevent this deadlock by setting up runtime_in_callers before calling __go_get_backtrace_state. Found while investigating golang/go#29448. Will add a test in the next CL. Updates golang/go#29448. Reviewed-on: https://go-review.googlesource.com/c/156037 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267590 138bc75d-0d04-0410-961f-82ee72b054a4
With gccgo, if a profiling signal arrives in certain time during traceback, it may crash or hang. The fix is CL 156037 and CL 156038. This CL adds a test. Updates #29448. Change-Id: Idb36af176b4865b8fb31a85cad185ed4c07ade0c Reviewed-on: https://go-review.googlesource.com/c/156018 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
Change https://golang.org/cl/156697 mentions this issue: |
This is following CL 156038. doscanstackswitch uses the same mechanism of switching goroutines as getTraceback, and so has the same problem as described in issue golang/go#29448. This CL applies the same fix. Change-Id: I0da9996b0f73755f0171c7c10be6c77cb298b517 Reviewed-on: https://go-review.googlesource.com/c/156697 Reviewed-by: Ian Lance Taylor <[email protected]>
Currently, when collecting a traceback for another goroutine, getTraceback calls gogo(gp) switching to gp, which will resume in mcall, which will call gtraceback, which will set up gp->m. There is a gap between setting the current running g to gp and setting gp->m. If a profiling signal arrives in between, sigtramp will see a non-nil gp with a nil m, and will seg fault. Fix this by setting up gp->m first. Fixes golang/go#29448. Reviewed-on: https://go-review.googlesource.com/c/156038 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267658 138bc75d-0d04-0410-961f-82ee72b054a4
This is following CL 156038. doscanstackswitch uses the same mechanism of switching goroutines as getTraceback, and so has the same problem as described in issue golang/go#29448. This CL applies the same fix. Reviewed-on: https://go-review.googlesource.com/c/156697 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267661 138bc75d-0d04-0410-961f-82ee72b054a4
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
This program, compiled with gccgo, crashes with high probability. Here is the stack trace at crash:
The signal arrives half-way through a goroutine switch, where
gp
is not nil butgp->m
is nil. FunctiongetTraceback
switches togp
without setting up an m. Whensetcontext
finishes, it will be inmcall
, which will callgtraceback
, which will set up an m. But there is a gap and profiling signal could arrive in between. Maybe we could set up an m earlier, ingetTraceback
, before switching togp
.Another possibility would be in
sigtramp
, treating "gp
is not nil butgp->m
is nil" the same asgp
is nil.Found this initially when investigating a similar seg fault with precise stack scan (with gollvm), where it uses a similar way to switch goroutine when scanning another goroutine's stack.
cc @ianlancetaylor @thanm
The text was updated successfully, but these errors were encountered: