]> Cypherpunks repositories - gostls13.git/commit
runtime: fix GoroutineProfile stacks not getting null terminated
authorFelix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Fri, 30 Aug 2024 06:17:19 +0000 (08:17 +0200)
committerCarlos Amedee <carlos@golang.org>
Wed, 25 Sep 2024 17:31:06 +0000 (17:31 +0000)
commit49e542aa85b7c2d9f6cf50de00843b455bc1e635
tree4d17738ea9b5241025c1b29ba00228e48a093563
parentc64ca8c6ef13723b9f25f4b5e1c7b6986b958d2e
runtime: fix GoroutineProfile stacks not getting null terminated

Fix a regression introduced in CL 572396 causing goroutine stacks not
getting null terminated.

This bug impacts callers that reuse the []StackRecord slice for multiple
calls to GoroutineProfile. See https://github.com/felixge/fgprof/issues/33
for an example of the problem.

Add a test case to prevent similar regressions in the future. Use null
padding instead of null termination to be consistent with other profile
types and because it's less code to implement. Also fix the
ThreadCreateProfile code path.

Fixes #69243

Change-Id: I0b9414f6c694c304bc03a5682586f619e9bf0588
Reviewed-on: https://go-review.googlesource.com/c/go/+/609815
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/mprof.go
src/runtime/pprof/pprof_test.go