]> Cypherpunks repositories - gostls13.git/commit
runtime: fix generation skew with trace reentrancy
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 30 Sep 2025 23:54:07 +0000 (23:54 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 20 Oct 2025 20:32:29 +0000 (13:32 -0700)
commitdc9a3e2a658176fe1884d65d5a0e7516145404eb
tree6c2dd4a9a3f039ac371814d81fd0a2a8e2efe93a
parentdf33c170919faca6ea849ee23fb0af6971fddc5b
runtime: fix generation skew with trace reentrancy

Currently when performing multiple nested traceAcquires, we re-read
trace.gen on subsequent reads. But this is invalid, since a generation
transition may happen in between a traceAcquire and a nested
traceAcquire. The first one will produce a traceLocker with a gen from
the previous generation, and the second will produce a traceLocker from
the next generation. (Note: generations cannot _complete_ advancement
under traceAcquire, but trace.gen can move forward.) The end result is
earlier events, from the nested traceAcquire, will write to a future
generation, and then previous events will write to a past generation.
This can break the trace.

(There are also a lot of comments left over talking about the
non-reentrancy of the tracer; we should look at those again.)

Change-Id: I08ac8cc86d41ab3e6061c5de58d657b6ad0d19d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/708397
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/traceruntime.go