Skip to content
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: race detector instrumentation broken in signal handlers #8627

Closed
mdempsky opened this issue Sep 2, 2014 · 5 comments
Closed

runtime: race detector instrumentation broken in signal handlers #8627

mdempsky opened this issue Sep 2, 2014 · 5 comments

Comments

@mdempsky
Copy link
Contributor

mdempsky commented Sep 2, 2014

See https://golang.org/cl/132440043.  Currently the race detector
instrumentation fails within a signal handler, such as trying to call copy() in
cpuprof.go.  The cause seems to be similar to https://golang.org/cl/137910043
where racectx for gsignal needs to be initialized too, but as mentioned in the cpuprof
code review, that change alone didn't seem sufficient to fix the problem.
@dvyukov
Copy link
Member

dvyukov commented Sep 2, 2014

Comment 1:

Labels changed: added release-go1.4, repo-main, racedetector.

Status changed to Accepted.

@dvyukov
Copy link
Member

dvyukov commented Sep 2, 2014

Comment 2:

Wait-wait-wait. The fix is incorrect and all the conclusions. What is wrong here is that
race detector sees events happening on system stacks g0/gsignal. There is no possible
semantic meaning for these events. At best they will lead to degraded performance if
handled. And at worst to false positives as race detector does not see most of the
synchronization happening inside of runtime (that g0 synchronizes with curg during
mcall, for example). And if we will try to teach race detector about all that
synchronization, then it will lead to massive false negatives for user code.
Runtime code is not instrumented by compiler on purpose. The manual instrumentation in
copy/growslice/hashmaps was only happening on user gs to date. Now it happens on
g0/gsignal as we have much more Go code in runtime. The events like copy in mprof are
implementation details of runtime, they need to be ignored by race detector. And
g0/gsignal must not have race context at all.
There is a possible case when g0 executes an interesting memory access or
synchronization on behalf of a user goroutine. For example, if growslice would call onM
and do the rest of work on g0. We does not seem to have such cases now. If such case is
discovered, then race detector will need to use g->m->curg->racectx to handle such
events. But we still don't need racectx for g0.

@gopherbot
Copy link
Contributor

Comment 3:

CL https://golang.org/cl/137070043 mentions this issue.

@dvyukov
Copy link
Member

dvyukov commented Sep 3, 2014

Comment 4:

This issue was closed by revision 467a6d2.

Status changed to Fixed.

@mdempsky
Copy link
Contributor Author

mdempsky commented Sep 3, 2014

Comment 5:

From dvyukov's comment in https://golang.org/cl/137070043#msg4 ("I agree that
we need something more systematic in future. But the change will complex and subtle and
can potentially severely degrade performance. I don't want to rewrite it just before
release."), it seems like the commit is just the minimum to allow copy() from a signal
handler.  I suspect we want to keep the issue open (but probably targeted towards 1.5)
to track progress on the more systematic fix?

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Ignore memory access on g0/gsignal.
See the issue for context and explanation.
Fixes golang#8627.

LGTM=khr
R=golang-codereviews, mdempsky, khr
CC=golang-codereviews, rsc
https://golang.org/cl/137070043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Ignore memory access on g0/gsignal.
See the issue for context and explanation.
Fixes golang#8627.

LGTM=khr
R=golang-codereviews, mdempsky, khr
CC=golang-codereviews, rsc
https://golang.org/cl/137070043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants