-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/cgo: hang in pthread_cond_wait
during GC start-the-world on macOS
#45765
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
Comments
The backtrace is quite confusing, but it seems to be stuck in waiting for the world to start again? |
pthread_cond_wait
from mallocgc
on macOSpthread_cond_wait
during GC start-the-world on macOS
We can't trust lldb to provide a correct stack trace for a Go program. The stack trace that is shown is clearly impossible, and we don't know which parts are correct and which parts are not. |
Everything below runtime.asmcgocall is probably incorrect. |
The backtrace seems repeating some of the callers after
So in my opnion this might be trusted?...
|
No, it cannot. E.g.
Clearly pthread_cond_wait does not call startTheWorldWithSema. |
Oh, I see, it seems like the backtrace is messed with callstacks from many goroutines?... Now I doubt that nginx blocks some threads where Cgo needs to do GC works so it hangs at the cond wait 🤔. I will try |
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?
I wrote an nginx module that receives a JSON request and handles it with Cgo functions. In the Cgo handler, I also used an ANTLR4-generated parser to parse some strings. The grammar is a bit complicated and it's doing a lot of recursive works.
It's weird that the parser could always give the results for the first time (receiving the HTTP response), but for the second time, it hangs at the
mallocgc
forever.Below is the partial backtrace from
lldb
.It seems like
mallocgc
triggers a sleep with a negative duration so it calls thepthread_cond_wait
in functionsemasleep
, and it hangs.What did you expect to see?
My program could safely pass through the
mallocgc
😢What did you see instead?
Partial backtrace via
lldb
:The process sample:
The text was updated successfully, but these errors were encountered: