]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.21] runtime: put ReadMemStats debug assertions behind a double...
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 27 Nov 2023 22:27:32 +0000 (22:27 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 4 Jan 2024 21:34:32 +0000 (21:34 +0000)
commit43818206dc7974cb8ce080e0c5e0bce3563029f7
tree87dbb0d63d25f961b4e17cbd9d81187d3c00ff2a
parentcf65d74bc5198da0561252ab06a3f75961988338
[release-branch.go1.21] runtime: put ReadMemStats debug assertions behind a double-check mode

ReadMemStats has a few assertions it makes about the consistency of the
stats it's about to produce. Specifically, how those stats line up with
runtime-internal stats. These checks are generally useful, but crashing
just because some stats are wrong is a heavy price to pay.

For a long time this wasn't a problem, but very recently it became a
real problem. It turns out that there's real benign skew that can happen
wherein sysmon (which doesn't synchronize with a STW) generates a trace
event when tracing is enabled, and may mutate some stats while
ReadMemStats is running its checks.

Fix this by synchronizing with both sysmon and the tracer. This is a bit
heavy-handed, but better that than false positives.

Also, put the checks behind a debug mode. We want to reduce the risk of
backporting this change, and again, it's not great to crash just because
user-facing stats are off. Still, enable this debug mode during the
runtime tests so we don't lose quite as much coverage from disabling
these checks by default.

For #64401.
Fixes #64410.

Change-Id: I9adb3e5c7161d207648d07373a11da8a5f0fda9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/545277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
(cherry picked from commit b2efd1de97402ec4b8fb4e9e0ec29c8e49e8e200)
Reviewed-on: https://go-review.googlesource.com/c/go/+/545557
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
src/runtime/export_test.go
src/runtime/gc_test.go
src/runtime/mstats.go