From: Michael Anthony Knyszek Date: Wed, 2 Apr 2025 01:46:45 +0000 (+0000) Subject: runtime: add package doc for checkfinalizer mode X-Git-Tag: go1.25rc1~191 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5b0b4c01ba44f372343ed003b297f50ee3c8ff67;p=gostls13.git runtime: add package doc for checkfinalizer mode Fixes #72949. Change-Id: I114eda73c57bc7d596eb1656e738b80c1cbe5254 Reviewed-on: https://go-review.googlesource.com/c/go/+/662039 Reviewed-by: Carlos Amedee Reviewed-by: Michael Pratt Auto-Submit: Michael Knyszek LUCI-TryBot-Result: Go LUCI --- diff --git a/src/runtime/extern.go b/src/runtime/extern.go index eb30b0566e..62dab74bc0 100644 --- a/src/runtime/extern.go +++ b/src/runtime/extern.go @@ -52,6 +52,21 @@ It is a comma-separated list of name=val pairs setting these named variables: cgocheck mode can be enabled using GOEXPERIMENT (which requires a rebuild), see https://pkg.go.dev/internal/goexperiment for details. + checkfinalizers: setting checkfinalizers=1 causes the garbage collector to run + multiple partial non-parallel stop-the-world collections to identify common issues with + finalizers and cleanups, like those listed at + https://go.dev/doc/gc-guide#Finalizers_cleanups_and_weak_pointers. If a potential issue + is found, the program will terminate with a description of all potential issues, the + associated values, and a list of those values' finalizers and cleanups, including where + they were created. It also adds tracking for tiny blocks to help diagnose issues with + those as well. The analysis performed during the partial collection is conservative. + Notably, it flags any path back to the original object from the cleanup function, + cleanup arguments, or finalizer function as a potential issue, even if that path might + be severed sometime later during execution (though this is not a recommended pattern). + This mode also produces one line of output to stderr every GC cycle with information + about the finalizer and cleanup queue lengths. Lines produced by this mode start with + "checkfinalizers:". + decoratemappings: controls whether the Go runtime annotates OS anonymous memory mappings with context about their purpose. These annotations appear in /proc/self/maps and /proc/self/smaps as