-
Notifications
You must be signed in to change notification settings - Fork 18k
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
runtime: msanwrite segfaults when called without a g on arm64 #34338
Comments
The cause is that when built with -buildmode=c-shared, the sigaction() of runtime/cgo_sigaction.go will call msanwrite() during libpreinit (before the runtime has set up a g). Unfortunately, on arm64, msancall() called by msanwrite() assumes that it is always called with a valid g, leading to a segfault. I will submit the fixed CL, checking for nil g in msancall() on arm64. |
/cc @bcmills and @ianlancetaylor who know much more about runtime/cgo than myself. |
The suggested change sounds correct. That is what the amd64 code already does. |
The change should be to |
@ianlancetaylor Yes, you are right. We need to check nil g to msancall() in runtime/msan_arm64.s. The fixed patch is ready and I will submit it. Thank you. |
Change https://golang.org/cl/196157 mentions this issue: |
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?
Run testsanitizers/TestShared test
What did you expect to see?
pass
What did you see instead?
The test failed.
../misc/cgo/testsanitizers
--- FAIL: TestShared (0.24s)
--- FAIL: TestShared/msan_shared (4.69s)
cshared_test.go:71:
/tmp/TestShared066999108/msan_shared
exited with exit status 77MemorySanitizer:DEADLYSIGNAL
==24668==ERROR: MemorySanitizer: SEGV on unknown address 0x000000000030 (pc 0xffff94b3e9d4 bp 0xffffef3ca388 sp 0xffffef3ca390 T24668)
==24668==The signal is caused by a READ memory access.
==24668==Hint: address points to the zero page.
#0 0xffff94b3e9d3 (/tmp/TestShared066999108/libmsan_shared.so+0x8e9d3)
FAIL
The text was updated successfully, but these errors were encountered: