Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: moduledata.typemap use after garbage collection #17680

Closed
crawshaw opened this issue Oct 31, 2016 · 1 comment
Closed

runtime: moduledata.typemap use after garbage collection #17680

crawshaw opened this issue Oct 31, 2016 · 1 comment
Milestone

Comments

@crawshaw
Copy link
Member

The runtime.moduledata map[typeOff]*_type object is created at run time and stored in the moduledata. The moduledata object is marked by the linker as SNOPTRDATA, so the reference is ignored by the GC. Running misc/cgo/testplugin/test.bash with GOGC=1 will eventually collect the typemap and crash.

bash:~/go/misc/cgo/testplugin$ GOGC=1 ./test.bash
unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x400c4cd]

goroutine 1 [running]:
runtime.throw(0x40e193b, 0x5)
    /Users/crawshaw/go/src/runtime/panic.go:596 +0x95 fp=0xc42003f648 sp=0xc42003f628
runtime.sigpanic()
    /Users/crawshaw/go/src/runtime/signal_unix.go:276 +0x28c fp=0xc42003f698 sp=0xc42003f648
runtime.mapaccess1_fast32(0x40c9240, 0xc4200a8120, 0x54c0, 0xc4200fa0e0)
    /Users/crawshaw/go/src/runtime/hashmap_fast.go:37 +0x16d fp=0xc42003f6c0 sp=0xc42003f698
runtime.typelinksinit()
    /Users/crawshaw/go/src/runtime/type.go:484 +0x59c fp=0xc42003f8b0 sp=0xc42003f6c0
plugin.lastmoduleinit(0x4802000, 0xc4200aa018, 0x5500000)
    /Users/crawshaw/go/src/runtime/plugin.go:48 +0x7c5 fp=0xc42003f990 sp=0xc42003f8b0
plugin.open(0xc420010200, 0x35, 0x0, 0x0, 0x0)
    /Users/crawshaw/go/src/plugin/plugin_dlopen.go:72 +0x241 fp=0xc42003fbb0 sp=0xc42003f990
plugin.Open(0xc420010200, 0x35, 0xc420010200, 0x35, 0x0)
    /Users/crawshaw/go/src/plugin/plugin.go:30 +0x35 fp=0xc42003fbe8 sp=0xc42003fbb0
main.main()
    /Users/crawshaw/go/misc/cgo/testplugin/src/host/host.go:59 +0x42c fp=0xc42003ff88 sp=0xc42003fbe8
runtime.main()
    /Users/crawshaw/go/src/runtime/proc.go:185 +0x20a fp=0xc42003ffe0 sp=0xc42003ff88
runtime.goexit()
    /Users/crawshaw/go/src/runtime/asm_amd64.s:2184 +0x1 fp=0xc42003ffe8 sp=0xc42003ffe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/crawshaw/go/src/runtime/asm_amd64.s:2184 +0x1

cc @mwhudson

@crawshaw crawshaw added this to the Go1.8 milestone Oct 31, 2016
@crawshaw crawshaw self-assigned this Oct 31, 2016
@gopherbot
Copy link

CL https://golang.org/cl/32430 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants