-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
ImplementationIssues describing a semantics-preserving change to the Go implementation.Issues describing a semantics-preserving change to the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
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:
- Detect when a finalizer or cleanup function fully blocks the goroutine it's on and report it as a potential issue.
- Detect when a finalizer or cleanup is attached to a tiny alloc block. This will require additional state tracking.
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.
gavraz, bmizerany, tmthrgd, florianl, rittneje and 2 more
Metadata
Metadata
Assignees
Labels
ImplementationIssues describing a semantics-preserving change to the Go implementation.Issues describing a semantics-preserving change to the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Done