Proposal Details
This proposal involves an experimental change to the garbage collector that allows it detect some types goroutine leaks (a.k.a. partial deadlocks in the community).
The approach uses memory reachability as computed by the garbage collector to single out goroutines blocked over concurrency primitives that cannot be accessed by any (transitively) runnable goroutines. It is already described at length in this publication.
This proposal follows the implementation according to the available artifact, but with the following changes:
- The stacks of leaked goroutines (and other heap resources reachable only through the stacks) are not forcefully reclaimed by the GC; instead, deadlocked goroutines are flagged as such and treated as always reachable for future GC cycles. This preserves the soundness of leak detection, but it is less precise than the published variant.
- The GC cycle performing goroutine leak detection would be triggered via an API instead of being enabled for every cycle. This significantly reduces performance penalties.
- In the current implementation, changes are enabled via the deadlockgc
flag for GOEXPERIMENT
(like Green Tea GC)
Comment From: seankhliao
I think this would benefit from an implementation before a proposal.