runtime: add debug mode for finalizers and cleanups #72949
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
Implementation
Issues describing a semantics-preserving change to the Go implementation.
Milestone
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: