aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mprof.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r--src/runtime/mprof.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go
index 684ab0b055..eb7231aec2 100644
--- a/src/runtime/mprof.go
+++ b/src/runtime/mprof.go
@@ -576,12 +576,17 @@ func Stack(buf []byte, all bool) int {
pc := getcallerpc(unsafe.Pointer(&buf))
systemstack(func() {
g0 := getg()
+ // Force traceback=1 to override GOTRACEBACK setting,
+ // so that Stack's results are consistent.
+ // GOTRACEBACK is only about crash dumps.
+ g0.m.traceback = 1
g0.writebuf = buf[0:0:len(buf)]
goroutineheader(gp)
traceback(pc, sp, 0, gp)
if all {
tracebackothers(gp)
}
+ g0.m.traceback = 0
n = len(g0.writebuf)
g0.writebuf = nil
})