-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: Windows profilem may profile Ms after unminit #50557
Comments
It looks like cc @aclements |
I see a few different options here:
|
I think 4 is a good idea, for preemption. Not sure about profiling, maybe we could do 3. Maybe we put setting/unsetting stack bounds in the same lock. Or we could re-check mp.thread after the thread is suspended? (is there any ABA problem?) Not sure about the implication of suspending thread with the lock held. I haven't thought it carefully, but it sounds a bit dangerous (for deadlock). Maybe it is fine. |
2022-09-05T08:08:24-af7f417/windows-amd64-longtest Is this exactly this issue? It looks really similar. A nil pointer dereference in |
I believe that is #54885. |
profileLoop
partially synchronizes withunminit
viamp.threadLock
, but it dropsthreadLock
prior to_SuspendThread
andprofilem
.Thus profiling may race with
dropm
, resulting inprofilem
running on an "extra" M which is no longer in use by Go and whose previous thread is running C code.In theory, this should result in
gFromSP
returning nil (as logically there should not be a G at all since this isn't a Go thread), which may makesigprof
crash, as it assumesgp != nil
. However, in practice the SP likely still falls in themp.g0
stack range and things end up not crashing, though with a non-meaningful profile sample.I've been able to easily detect this condition in practice with a C thread repeatedly calling a Go function and
profilem
checking ifmp.thread
is still set.cc @cherrymui
The text was updated successfully, but these errors were encountered: