From c58f58b9f8df0bde53bb5bc20b5ea97d34b1531d Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 9 May 2025 18:53:06 +0000 Subject: runtime: mark and identify tiny blocks in checkfinalizers mode 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 Auto-Submit: Michael Knyszek Reviewed-by: Michael Pratt Reviewed-by: Carlos Amedee --- src/runtime/runtime1.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/runtime/runtime1.go') diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go index 9a4e15c95e..975d401694 100644 --- a/src/runtime/runtime1.go +++ b/src/runtime/runtime1.go @@ -333,14 +333,14 @@ var debug struct { traceCheckStackOwnership int32 profstackdepth int32 dataindependenttiming int32 - checkfinalizers int32 // debug.malloc is used as a combined debug check // in the malloc function and should be set // if any of the below debug options is != 0. - malloc bool - inittrace int32 - sbrk int32 + malloc bool + inittrace int32 + sbrk int32 + checkfinalizers int32 // traceallocfree controls whether execution traces contain // detailed trace data about memory allocation. This value // affects debug.malloc only if it is != 0 and the execution @@ -440,7 +440,7 @@ func parsedebugvars() { // apply environment settings parsegodebug(godebug, nil) - debug.malloc = (debug.inittrace | debug.sbrk) != 0 + debug.malloc = (debug.inittrace | debug.sbrk | debug.checkfinalizers) != 0 debug.profstackdepth = min(debug.profstackdepth, maxProfStackDepth) // Disable async preemption in checkmark mode. The following situation is -- cgit v1.3-5-g9baa