-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: add debug mode for finalizers and cleanups #72949
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
Related Issues (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Change https://go.dev/cl/634599 mentions this issue: |
Change https://go.dev/cl/662135 mentions this issue: |
Change https://go.dev/cl/662038 mentions this issue: |
Change https://go.dev/cl/662039 mentions this issue: |
Change https://go.dev/cl/662037 mentions this issue: |
This new debug mode detects cleanup/finalizer leaks using checkmark mode. It runs a partial GC using only specials as roots. If the GC can find a path from one of these roots back to the object the special is attached to, then the object might never be reclaimed. (The cycle could be broken in the future, but it's almost certainly a bug.) This debug mode is very barebones. It contains no type information and no stack location for where the finalizer or cleanup was created. For #72949. Change-Id: Ibffd64c1380b51f281950e4cfe61f677385d42a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/634599 Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Michael Pratt <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Michael Knyszek <[email protected]>
This change adds a new special kind called CheckFinalizer which is used to annotate finalizers and cleanups with extra information about where that cleanup or finalizer came from. For #72949. Change-Id: I3c1ace7bd580293961b7f0ea30345a6ce956d340 Reviewed-on: https://go-review.googlesource.com/c/go/+/662135 Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
This change adds support for identifying cleanups and finalizers attached to tiny blocks to checkfinalizers mode. It also notes a subtle pitfall, which is that the cleanup arg, if tiny-allocated, could end up co-located with the object with the cleanup attached! Oops... For #72949. Change-Id: Icbe0112f7dcfc63f35c66cf713216796a70121ce Reviewed-on: https://go-review.googlesource.com/c/go/+/662037 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
This change dumps a scan trace (each pointer marked and where it came from) for the partial GC cycle performed by checkfinalizers mode when checkfinalizers>1. This is useful for quickly understanding why certain values are reachable without having to pull out tools like viewcore. For #72949. Change-Id: Ic583f80e9558cdfe1c667d27a1d975008dd39a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/662038 Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Finalizers are notoriously difficult to work with due to all the subtleties you need to be aware of. Cleanups have resolved several finalizer issues, but still carry some of the same issues.
To help detect misuse, I'd like to propose a new debug mode (
GODEBUG
) that runs a partial GC cycle during mark termination to detect reference cycles for finalizers and references from cleanup roots to the objects they're attached to. This debug mode can also include three additional checkers:I'll also note that execution traces would be a great place to analyze inefficiencies due to finalizers and/or cleanups.
https://go.dev/cl/634599 is a start.
The text was updated successfully, but these errors were encountered: