-
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
runtime: deadlock detector false positive on Windows #56989
Comments
(CC @golang/runtime @golang/windows) I suspect that the deadlock detector is triggering because all of the threads created by the Go runtime are blocked, and it doesn't know about other threads created by system calls (such as, in this case, I wonder: would it suffice to have calls to (Or are there other Windows library functions that create meaningful background threads, don't require cgo, and also don't require a callback argument?) |
Another relevant question would be: Are
Having |
I think you can already do that fairly easily today by intentionally leaking a timer: _ = time.NewTimer(time.Duration(math.MaxInt64)) // Disable deadlock detection. |
Personally I'm OK with the Go runtime flagging that as a deadlock. 😅
You'd also have to pin in (#46787) and mark it executable. |
I think you can do the dynamic compilation thing without unsafe, though the examples become increasingly pathological. I think it comes down to the fact that A slightly more normal example might be loading a DLL, If we are adopting the position that it is valid for the deadlock detector to kill the process in the "impossible to re-enter the Go world" situation, should that be part of the language spec? My gut feeling would be: fix the case in the original example where it is possible to call back into Go code, and consider the other situations a "wont-fix" sort of bug. |
In triage, we're thinking that maybe what the runtime should do is disable the deadlock detector on any syscalls that take a callback. However, enumerating all of those seems potentially difficult. Alternatively we just disable the deadlock detector on Windows, which would be a shame (though, the deadlock detector isn't particularly sophisticated). |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe 1.19.3 to be the latest release at the moment, so yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
deadlock-example.zip
See the attached zip file. There are 4 versions of the same program. Version A triggers the deadlock detector. I wanted to test this program with the deadlock detector disabled but AFAIK there is no explicit way to do that, so I created 3 other versions of the program (B, C, and D from the zip file) which avoid the deadlock detector in various ways.
include "C"
, which as far as I can tell, disables the deadlock detector, even if there is no actual C code. This version of the program works as expected, proving that it is not a true deadlock.time.Sleep()
in a loop. This version of the program works as expected.What did you expect to see?
Note that you do have to wait for something on your Windows computer to actually generate an event. Manually checking for Windows updates is a fairly easy way to trigger one, though be warned the button to check for updates is de-bounced to about once per minute.
What did you see instead?
The text was updated successfully, but these errors were encountered: