-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: -msan / -asan stack corruption with CPU profiling and SetCgoTraceback context callback #71395
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
Labels
BugReport
Issues describing a possible bug in the Go implementation.
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Comments
Change https://go.dev/cl/643875 mentions this issue: |
Change https://go.dev/cl/643897 mentions this issue: |
Change https://go.dev/cl/643918 mentions this issue: |
gopherbot
pushed a commit
to golang/build
that referenced
this issue
Jan 23, 2025
linux-arm64 is a first class port with no coverage of ASAN or MSAN modes. We already have a clang15 builder, so adding ASAN and MSAN should be trivial (fingers crossed). For golang/go#71395. For golang/go#70054. Change-Id: I6a6a636c7a41147b1b22933db946ca838d3696f4 Reviewed-on: https://go-review.googlesource.com/c/build/+/643918 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
gopherbot
pushed a commit
that referenced
this issue
May 19, 2025
The tests using testprog / testprogcgo are currently not covered on the asan/msan/race builders because they don't build testprog with the sanitizer flag. Explicitly pass the flag if the test itself is built with the sanitizer. There were a few tests that explicitly passed -race (even on non-race builders). These tests will now only run on race builders. For #71395. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15,gotip-linux-amd64-race Change-Id: I6a6a636ce8271246316a80d426c0e4e2f6ab99c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/643897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
BugReport
Issues describing a possible bug in the Go implementation.
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsFix
The path to resolution is known, but the work has not been done.
msancall
andasancall
are used to call into the MSAN and ASAN C runtimes, respectively.These wrappers need to handle stack switching, similar to
asmcgocall
.If the caller is running on
g0
, then they just perform the call, otherwise they switch SP tog0.sched.sp
and then make the call. This is normally fine, but in a signal context we will be ongsignal
(notg0
!), but the code the signal interrupted may have been ong0
. By usingg0.sched.sp
, the MSAN/ASAN call will scribble all over the stack that the interrupted code is using.As far as I know, MSAN/ASAN calls are possible from signal context in only one case:
runtime.cgoContextPCs
containsmsanwrite
/asanwrite
calls.runtime.cgoContextPCs
is reachable from the SIGPROF signal handler:runtime.sigprof
->runtime.tracebackPCs
->runtime.(*unwinder).cgoCallers
->runtime.cgoContextPCs
.runtime.SetCgoTraceback
. Note that both thetraceback
andcontext
handlers must be registered. The latter is required becauseruntime.cgoContextPCs
only calls the traceback function ifgp.cgoCtxt
is active, which requires a context handler.https://go.dev/cl/643875 contains a reproducer. The allocator runs portions on the system stack, so with MSAN/ASAN plus profiling, we see crashes due to stack corruption in the allocator.
I haven't tested older versions, but this code hasn't changed in a while, so I suspect that 1.22 and 1.23 are also affected.
The text was updated successfully, but these errors were encountered: