-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: segfault in _tsan_enter_func
from systemstack when called in race mode from a generic function
#60439
Comments
CC @golang/compiler I marked this as cmd/compile because it seems like it might be a race instrumentation issue? I'm not familiar with the race detector's invariants, so I'm not quite sure what's going on here. |
The test notably does not fail if:
|
The problem here is when I can look into this, but it only affects the runtime, so it seems relatively low priority unless it causes problems for testing. You should be able to workaround the issue for now by making sure any instantiations happen within package runtime. |
+1 to very low priority. Thanks for taking the time to look into it! |
I think the issue here is in walk.instrument. We're deciding whether to instrument a function based on base.Flag.Race and base.Compiling, which look at the current compilation unit's flags. But for functions instantiated across compilation unit boundaries (e.g., for generics, though theoretically this could affect other generated functions like equality and hash functions too), this isn't necessarily correct. The fix should be to ensure IR builders set the Norace pragma as appropriate. |
How about making walk.instrument skips runtime functions? Something like this:
|
Change https://go.dev/cl/502895 mentions this issue: |
@cuonglm We need to also prevent runtime functions from getting inlined into other packages, otherwise they could still get instrumented that way. |
This came when trying to write some runtime test code that called
systemstack
from a generic function. It's possible this is just not allowed for some reason, but it was surprising to me.Here's a patch for reproducing the issue.
I can produce the failure by running this command, with the above patch applied.
Here's the failure:
When I poke at the faulting thread in
gdb
, it segfaults when calling_tsan_enter_func
at entry to the function passed tosystemstack
.The text was updated successfully, but these errors were encountered: