-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: inlining in bgsweep leads to livelock #73499
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
Root cause of bugThe deadlock occurs because another goroutine is constantly trying to stop the mark phase (while holding stw lock). Here is part of its back-trace:
The function
However, the main issue is that
Goroutines are not preemtible when it holds any locks. And |
I also have few solutions for this bug. I posted them in my original comment. Furthermore, I will also provide them as separate CL's a little bit later. |
Thank you for opening the issue, did you encounter the problem only on a pending CL? I saw the go version is |
Yes, as of now this doesn't happen in release versions.
I initially posted this in original issue #69046. But I decided that this problem should be in separate issues, because this is a subtle problem of inlining in runtime (and can come up any time inlining or something related changes). If you think that it is best to discus it in the context of the original issue, then let me know =). |
I think this is fine to discuss in this new issue, this problem is a bit separate from #69046. (Though either place is fine TBH). I think your first solution (adding an additional |
Thanks for filing an issue and for the thorough analysis. Either solution you described would work, I think. However, I agree with @prattmic and prefer the explicit preemption point. It's a bit simpler since we're treating the background sweeper more like a regular goroutine, which is easier to reason about. Every time we add a Another alternative would be to have @ArsenySamoylov would you like to send a change? You can follow the instructions at https://go.dev/doc/contribute, or if you prefer I can work on sending a patch for this. Thanks again! |
Go version
go version devel go1.24-3cdf88bffa Thu Nov 7 21:34:06 2024 +0300 linux/arm64
Output of
go env
in your module/workspace:What did you do?
When running
go1
BinaryTree17
benchmark with PGO using CL#626295 cmd/compile: support multiple levels of inlining using PGO (see TODO in src/cmd/compile/internal/inline/inl.go:892). I encountered deadlock. Here is my original post about this problem issues#69046Reproducing bug
Remove TODO part from https://go.dev/cl/626295. Complie https://go.dev/play/p/f7HGymVik58 with PGO:
What did you see happen?
Deadlock
What did you expect to see?
Happy end, not a deadlock.
The text was updated successfully, but these errors were encountered: