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/race: sigsegv when using cgo callbacks with the race detector enabled #10874

Closed
Thinkofname opened this issue May 15, 2015 · 3 comments
Closed
Milestone

Comments

@Thinkofname
Copy link

Only tested on linux/amd64. A simple way to reproduce this is to run the tests in misc/cgo/test
with the race detector enabled. It should crash as follows:

~/go/misc/cgo/test • GOTRACEBACK=2 go test -v -race
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x0 pc=0x415885]

runtime stack:
runtime.throw(0x769db0, 0x2a)
    /home/matt/go/src/runtime/panic.go:527 +0x96 fp=0x7ffff9f37c10 sp=0x7ffff9f37bf8
runtime.sigpanic()
    /home/matt/go/src/runtime/sigpanic_unix.go:12 +0x5d fp=0x7ffff9f37c60 sp=0x7ffff9f37c10

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0x4317f0, 0xc20804bef8, 0x0)
    /home/matt/go/src/runtime/cgocall.go:125 +0xc5 fp=0xc20804bed8 sp=0xc20804beb0
_/home/matt/go/misc/cgo/test._Cfunc_lockOSThreadC()
    ??:0 +0x56 fp=0xc20804bef8 sp=0xc20804bed8
_/home/matt/go/misc/cgo/test.init.1()
    /home/matt/go/misc/cgo/test/issue3775.go:23 +0x2d fp=0xc20804bf08 sp=0xc20804bef8
_/home/matt/go/misc/cgo/test.init()
    _/home/matt/go/misc/cgo/test/_test/_obj_test/_cgo_import.go:1 +0x1859 fp=0xc20804bf88 sp=0xc20804bf08
main.init()
    _/home/matt/go/misc/cgo/test/_test/_testmain.go:172 +0x9c fp=0xc20804bf98 sp=0xc20804bf88
runtime.main()
    /home/matt/go/src/runtime/proc.go:100 +0x220 fp=0xc20804bfe0 sp=0xc20804bf98
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc20804bfe8 sp=0xc20804bfe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc20803afe8 sp=0xc20803afe0

goroutine 2 [runnable]:
runtime.forcegchelper()
    /home/matt/go/src/runtime/proc.go:144 fp=0xc2080267e0 sp=0xc2080267d8
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc2080267e8 sp=0xc2080267e0
created by runtime.init.4
    /home/matt/go/src/runtime/proc.go:141 +0x32

goroutine 3 [GC sweep wait]:
runtime.gopark(0x78d008, 0x140b740, 0x719b50, 0xd, 0x44df14, 0x1)
    /home/matt/go/src/runtime/proc.go:185 +0x123 fp=0xc208026f68 sp=0xc208026f38
runtime.goparkunlock(0x140b740, 0x719b50, 0xd, 0x14, 0x1)
    /home/matt/go/src/runtime/proc.go:191 +0x5b fp=0xc208026fa0 sp=0xc208026f68
runtime.bgsweep(0xc208056000)
    /home/matt/go/src/runtime/mgcsweep.go:51 +0xba fp=0xc208026fd8 sp=0xc208026fa0
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc208026fe0 sp=0xc208026fd8
created by runtime.gcenable
    /home/matt/go/src/runtime/mgc.go:171 +0x5a

goroutine 4 [runnable]:
runtime.runfinq()
    /home/matt/go/src/runtime/mfinal.go:140 fp=0xc2080277e0 sp=0xc2080277d8
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc2080277e8 sp=0xc2080277e0
created by runtime.createfing
    /home/matt/go/src/runtime/mfinal.go:135 +0x67

goroutine 5 [runnable]:
os/signal.loop()
    /home/matt/go/src/os/signal/signal_unix.go:20 fp=0xc208027fe0 sp=0xc208027fd8
runtime.goexit()
    /home/matt/go/src/runtime/asm_amd64.s:1670 +0x1 fp=0xc208027fe8 sp=0xc208027fe0
created by os/signal.init.1
    /home/matt/go/src/os/signal/signal_unix.go:28 +0x4c
exit status 2
FAIL    _/home/matt/go/misc/cgo/test    0.008s

The common thing between the failing test and the issue with my own code seems to be callbacks from cgo into go

@ianlancetaylor
Copy link
Contributor

CC @dvyukov

I don't think we can reliably use the race detector in a cgo program, but it would be nicer if we didn't crash.

@rsc
Copy link
Contributor

rsc commented Jul 21, 2015

This is a regression since 1.4.

@rsc rsc modified the milestones: Go1.5, Go1.5Maybe Jul 21, 2015
@gopherbot
Copy link

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

@rsc rsc closed this as completed in 75d7795 Jul 22, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
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

4 participants