From a7c3de705287d56e3bea8a84ed9a56e4102d3f39 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Thu, 10 Aug 2023 14:02:03 +0800 Subject: [PATCH] runtime: document maxStack and m.createstack in more details Change-Id: If93b6cfa5a598a5f4101c879a0cd88a194e4a6aa Reviewed-on: https://go-review.googlesource.com/c/go/+/518116 Reviewed-by: Dmitri Shuralyov Reviewed-by: Michael Knyszek TryBot-Result: Gopher Robot Run-TryBot: Andy Pan --- src/runtime/mprof.go | 5 ++++- src/runtime/runtime2.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index 45f107722a..937194a238 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -39,7 +39,10 @@ const ( // size of bucket hash table buckHashSize = 179999 - // max depth of stack to record in bucket + // maxStack is the max depth of stack to record in bucket. + // Note that it's only used internally as a guard against + // wildly out-of-bounds slicing of the PCs that come after + // a bucket struct, and it could increase in the future. maxStack = 32 ) diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 2a02e1fb3b..885b493bad 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -583,7 +583,7 @@ type m struct { alllink *m // on allm schedlink muintptr lockedg guintptr - createstack [32]uintptr // stack that created this thread. + createstack [32]uintptr // stack that created this thread, it's used for StackRecord.Stack0, so it must align with it. lockedExt uint32 // tracking for external LockOSThread lockedInt uint32 // tracking for internal lockOSThread nextwaitm muintptr // next m waiting for lock