Closed
Description
What version of Go are you using (go version
)?
go version go1.8 linux/amd64
What did you do?
Run a program with GOTRACEBACK=crash where some of the threads are on the system stack. This was observed in the go1.8.txt
traceback from https://groups.google.com/d/topic/golang-dev/PVwDFD7gDuk/discussion. It can be reproduced by running the following program with GOGC=1 GOTRACEBACK=crash
and sending it SIGQUIT (it may take a few tries since it's timing-dependent):
package main
import (
"runtime"
"time"
)
var slice = make([]*byte, 16<<20)
var ballast = mkTree(10)
var sink interface{}
func main() {
const count = 4
runtime.GOMAXPROCS(count + 1)
// Get the garbage collector going so typedslicecopy switches
// to the system stack. We have to do this before starting
// loop since GC won't be able to start once we're in loop.
go func() {
for {
sink = make([]byte, 16<<20)
}
}()
time.Sleep(10 * time.Millisecond)
for i := 0; i < count; i++ {
go loop(i)
}
select {}
}
func loop(i int) {
for {
for j := 0; j < 0x7fffffff; j++ {
// This runs on the system stack when GC is active.
copy(slice, slice[1:])
}
}
}
type node struct {
l, r *node
}
func mkTree(depth int) *node {
if depth <= 0 {
return nil
}
return &node{mkTree(depth - 1), mkTree(depth - 1)}
}
What did you expect to see?
A traceback with the full stacks of all goroutines in loop
.
What did you see instead?
When a loop
goroutine is on the system stack when the traceback happens, we only see the system stack part:
SIGQUIT: quit
PC=0x44a0d8 m=4 sigcode=0
goroutine 0 [idle]:
runtime.memmove(0xc421459f30, 0xc421459f38, 0x8)
/home/austin/.cache/gover/1.8/src/runtime/memmove_amd64.s:168 +0x6a8 fp=0xc420081f20 sp=0xc420081f18
runtime.typedmemmove(0x459a00, 0xc421459f30, 0xc421459f38)
/home/austin/.cache/gover/1.8/src/runtime/mbarrier.go:246 +0x3c fp=0xc420081f58 sp=0xc420081f20
runtime.typedslicecopy.func1()
/home/austin/.cache/gover/1.8/src/runtime/mbarrier.go:362 +0x220 fp=0xc420081fb8 sp=0xc420081f58
runtime.systemstack(0xc42003a600)
/home/austin/.cache/gover/1.8/src/runtime/asm_amd64.s:327 +0x79 fp=0xc420081fc0 sp=0xc420081fb8
runtime.mstart()
/home/austin/.cache/gover/1.8/src/runtime/proc.go:1132 fp=0xc420081fc8 sp=0xc420081fc0
goroutine 36 [running]:
rax 0x459a00
rbx 0x8
rcx 0xc421459f30
rdx 0xc421459f38
rdi 0xc421459f30
rsi 0xc421459f38
rbp 0xc420081f48
rsp 0xc420081f18
r8 0x3
r9 0x0
r10 0xc421459f30
r11 0x474762
r12 0x0
r13 0x34
r14 0x0
r15 0xf3
rip 0x44a0d8
rflags 0x246
cs 0x33
fs 0x0
gs 0x0