]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] 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)
committerMichael Pratt <mpratt@google.com>
Mon, 21 Oct 2024 18:37:43 +0000 (18:37 +0000)
commit35c010ad6db5113f51e1867ab3d0108754a3264c
tree24f6eb116567a29cb0a0e0c1e7e102e69e45d1d2
parent6495ce0495041ba28fdbad8ae8b0e0996481e6f4
[release-branch.go1.23] 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 #69258

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>
(cherry picked from commit 49e542aa85b7c2d9f6cf50de00843b455bc1e635)
Reviewed-on: https://go-review.googlesource.com/c/go/+/621277
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/mprof.go
src/runtime/pprof/pprof_test.go