Skip to content

golang garbage collector crashes in preload mode #1931

@sporksmith

Description

@sporksmith

Broken out from #1549

When using preload-based interposition, golang's garbage collector aborts while parsing stacks.

Example program:

package main

import (
    "fmt"
)

func main() {
    for i := 0; i < 100; i++ {
      // Generate some garbage
      garbage := make([]int, 10000)
      fmt.Println("loop", i, ": ", &garbage[0])
    }
}
general:
  stop_time: 2000s

network:
  graph:
    type: 1_gbit_switch

hosts:
  host:
    network_node_id: 0
    processes:
    - path: ./test_gc
      start_time: 1s
      environment: GOMAXPROCS=1

Output:

$ cat build/src/test/golang/gc-shadow-preload.data/hosts/host/host.test_gc.1000.stderr 
runtime: unexpected return pc for runtime.gopark called from 0x1
stack: frame={sp:0xc000342f90, fp:0xc000342fb0} stack=[0xc000342800,0xc000343000)
000000c000342e90:  0000000000000004  000000000000000a 
000000c000342ea0:  000000000000002a  00007ffff4b59e2c 
000000c000342eb0:  000000c000000000  00007fff00000000 
000000c000342ec0:  00007fff0000002a  0000000000000045 
000000c000342ed0:  00007fff00000045  0000000000000000 
000000c000342ee0:  00007ffff57f48a0  0000000000000d68 
000000c000342ef0:  0000000000000000  00007ffff57f51a0 
000000c000342f00:  000000c0003434a0  000000c0003434c0 
000000c000342f10:  00007ffff4b5a000  000000c000343ed0 
000000c000342f20:  0000000000000064  00007ffff5682166 
000000c000342f30:  000000c0003435f0  000000c000343530 
000000c000342f40:  0000000000342ff0  000000c000000000 
000000c000342f50:  0000001e00000000  0000000000000000 
000000c000342f60:  00007ffff4b5a021  0000003000000000 
000000c000342f70:  ffffffffffffffff  0000000000000000 
000000c000342f80:  0000000000000002  000000c00000000a 
000000c000342f90: <0000000000000001  0000000000000020 
000000c000342fa0:  000000c00000001e !0000000000000001 
000000c000342fb0: >00007ffff4b5a021  000000000000001f 
000000c000342fc0:  00007fff0000001f  0000000000000000 
000000c000342fd0:  00007ffff57f48a0  0000000000000d68 
000000c000342fe0:  0000000000000000  00007ffff4b5a010 
000000c000342ff0:  ffffffffffffffff  00007fffec617038 
fatal error: unknown caller pc

runtime stack:
runtime.throw(0x7ffff6b89cff, 0x11)
	/home/jnewsome/opt/go/src/runtime/panic.go:1117 +0x74
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000000a80, 0x0, 0x0, 0x7fffffff, 0x7fffffffe708, 0x0, 0x0, ...)
	/home/jnewsome/opt/go/src/runtime/traceback.go:261 +0x1a45
runtime.scanstack(0xc000000a80, 0xc000335698)
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:749 +0x16f
runtime.markroot.func1()
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:233 +0xc6
runtime.markroot(0xc000335698, 0x16)
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:206 +0x385
runtime.gcDrainN(0xc000335698, 0x13d1b, 0x7fffffffe8a0)
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:1135 +0x131
runtime.gcAssistAlloc1(0xc000000180, 0x13d1b)
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:538 +0x112
runtime.gcAssistAlloc.func1()
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:449 +0x35
runtime.systemstack(0x7ffff6420b95)
	/home/jnewsome/opt/go/src/runtime/asm_amd64.s:379 +0x63
runtime.mstart()
	/home/jnewsome/opt/go/src/runtime/proc.go:1246

goroutine 1 [GC assist marking]:
runtime.systemstack_switch()
	/home/jnewsome/opt/go/src/runtime/asm_amd64.s:339 fp=0xc000355dd0 sp=0xc000355dc8 pc=0x7ffff6420d00
runtime.gcAssistAlloc(0xc000000180)
	/home/jnewsome/opt/go/src/runtime/mgcmark.go:448 +0x185 fp=0xc000355e30 sp=0xc000355dd0 pc=0x7ffff63c1a65
runtime.mallocgc(0x13880, 0x7ffff6e79aa0, 0x1, 0x0)
	/home/jnewsome/opt/go/src/runtime/malloc.go:961 +0xa13 fp=0xc000355eb8 sp=0xc000355e30 pc=0x7ffff63aa653
runtime.makeslice(0x7ffff6e79aa0, 0x2710, 0x2710, 0x4)
	/home/jnewsome/opt/go/src/runtime/slice.go:98 +0x6e fp=0xc000355ee8 sp=0xc000355eb8 pc=0x7ffff63ffa4e
()
	/home/jnewsome/projects/shadow/dev/src/test/golang/test_gc.go:10 +0x5f fp=0xc000355f88 sp=0xc000355ee8 pc=0x5555555561ff
runtime.main()
	/home/jnewsome/opt/go/src/runtime/proc.go:225 +0x2aa fp=0xc000355fe0 sp=0xc000355f88 pc=0x7ffff63e2aca
runtime.goexit()
	/home/jnewsome/opt/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc000355fe8 sp=0xc000355fe0 pc=0x7ffff64231c1

Metadata

Metadata

Assignees

Labels

Type: BugError or flaw producing unexpected results

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions