Using cgo in a program that calls Application.Run() causes a crash.
Here's a simple repro:
package main
import "C"
import "github.com/rivo/tview"
func main() {
tview.NewApplication().Run()
}
I did a bisect and found that the crash started occurring with this commit: b2dec96. That commit upgrades tcell, so this may actually be more of a tcell issue. Not sure.
I'm on this go version:
go version go1.17 darwin/amd64
Here's my error output:
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff2058acbe]
runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff2058acbe
stack: frame={sp:0x7ffeefbff3a8, fp:0x7ffeefbff3f8} stack=[0x7ffeefb80448,0x7ffeefbff4b0)
0x00007ffeefbff2a8: 0x01007ffeefbff2c8 0x0000000000000004
0x00007ffeefbff2b8: 0x000000000000001f 0x00007fff2058acbe
0x00007ffeefbff2c8: 0x0b01dfacedebac1e 0x0000000000000001
0x00007ffeefbff2d8: 0x0000000004032551 <runtime.throw+0x0000000000000071> 0x00007ffeefbff378
0x00007ffeefbff2e8: 0x000000000412c896 0x00007ffeefbff330
0x00007ffeefbff2f8: 0x0000000004032808 <runtime.fatalthrow.func1+0x0000000000000048> 0x000000000420dae0
0x00007ffeefbff308: 0x0000000000000001 0x0000000000000001
0x00007ffeefbff318: 0x00007ffeefbff378 0x0000000004032551 <runtime.throw+0x0000000000000071>
0x00007ffeefbff328: 0x000000000420dae0 0x00007ffeefbff368
0x00007ffeefbff338: 0x0000000004032790 <runtime.fatalthrow+0x0000000000000050> 0x00007ffeefbff348
0x00007ffeefbff348: 0x00000000040327c0 <runtime.fatalthrow.func1+0x0000000000000000> 0x000000000420dae0
0x00007ffeefbff358: 0x0000000004032551 <runtime.throw+0x0000000000000071> 0x00007ffeefbff378
0x00007ffeefbff368: 0x00007ffeefbff398 0x0000000004032551 <runtime.throw+0x0000000000000071>
0x00007ffeefbff378: 0x00007ffeefbff380 0x0000000004032580 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff388: 0x000000000412e9fd 0x000000000000002a
0x00007ffeefbff398: 0x00007ffeefbff3e8 0x0000000004048076 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff3a8: <0x000000000412e9fd 0x000000000420dae0
0x00007ffeefbff3b8: 0x01007ffeefbff428 0x0000000004743868
0x00007ffeefbff3c8: 0x00000000000006c0 0x000000000420e060
0x00007ffeefbff3d8: 0x00000000047438e0 0x00007ffeefbff438
0x00007ffeefbff3e8: 0x00007ffeefbff430 !0x00007fff2058acbe
0x00007ffeefbff3f8: >0x00007ffeefbff430 0x00000000041f0000
0x00007ffeefbff408: 0x0000000000000129 0x00000000040c1605 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff418: 0x00000000040637df <runtime.syscall+0x000000000000001f> 0x000000c000243bf8
0x00007ffeefbff428: 0x00000000047810a8 0x000000c000243bc8
0x00007ffeefbff438: 0x0000000004061670 <runtime.asmcgocall+0x0000000000000070> 0x00000000040181f5 <runtime.SetFinalizer.func2+0x0000000000000035>
0x00007ffeefbff448: 0x000000c0001aa6c0 0x0000000004130b78
0x00007ffeefbff458: 0x0000000000000010 0x000000000410c380
0x00007ffeefbff468: 0x0000000000000460 0x000000c0000001a0
0x00007ffeefbff478: 0x000000000405f789 <runtime.systemstack+0x0000000000000049> 0x0000000000000004
0x00007ffeefbff488: 0x000000000414faa0 0x000000000420dae0
0x00007ffeefbff498: 0x00007ffeefbff4e8 0x000000000405f685 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff4a8: 0x000000000405f63d <runtime.rt0_go+0x000000000000013d>
runtime.throw({0x412e9fd, 0x420dae0})
/opt/local/lib/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff2058acbe
stack: frame={sp:0x7ffeefbff3a8, fp:0x7ffeefbff3f8} stack=[0x7ffeefb80448,0x7ffeefbff4b0)
0x00007ffeefbff2a8: 0x01007ffeefbff2c8 0x0000000000000004
0x00007ffeefbff2b8: 0x000000000000001f 0x00007fff2058acbe
0x00007ffeefbff2c8: 0x0b01dfacedebac1e 0x0000000000000001
0x00007ffeefbff2d8: 0x0000000004032551 <runtime.throw+0x0000000000000071> 0x00007ffeefbff378
0x00007ffeefbff2e8: 0x000000000412c896 0x00007ffeefbff330
0x00007ffeefbff2f8: 0x0000000004032808 <runtime.fatalthrow.func1+0x0000000000000048> 0x000000000420dae0
0x00007ffeefbff308: 0x0000000000000001 0x0000000000000001
0x00007ffeefbff318: 0x00007ffeefbff378 0x0000000004032551 <runtime.throw+0x0000000000000071>
0x00007ffeefbff328: 0x000000000420dae0 0x00007ffeefbff368
0x00007ffeefbff338: 0x0000000004032790 <runtime.fatalthrow+0x0000000000000050> 0x00007ffeefbff348
0x00007ffeefbff348: 0x00000000040327c0 <runtime.fatalthrow.func1+0x0000000000000000> 0x000000000420dae0
0x00007ffeefbff358: 0x0000000004032551 <runtime.throw+0x0000000000000071> 0x00007ffeefbff378
0x00007ffeefbff368: 0x00007ffeefbff398 0x0000000004032551 <runtime.throw+0x0000000000000071>
0x00007ffeefbff378: 0x00007ffeefbff380 0x0000000004032580 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff388: 0x000000000412e9fd 0x000000000000002a
0x00007ffeefbff398: 0x00007ffeefbff3e8 0x0000000004048076 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff3a8: <0x000000000412e9fd 0x000000000420dae0
0x00007ffeefbff3b8: 0x01007ffeefbff428 0x0000000004743868
0x00007ffeefbff3c8: 0x00000000000006c0 0x000000000420e060
0x00007ffeefbff3d8: 0x00000000047438e0 0x00007ffeefbff438
0x00007ffeefbff3e8: 0x00007ffeefbff430 !0x00007fff2058acbe
0x00007ffeefbff3f8: >0x00007ffeefbff430 0x00000000041f0000
0x00007ffeefbff408: 0x0000000000000129 0x00000000040c1605 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff418: 0x00000000040637df <runtime.syscall+0x000000000000001f> 0x000000c000243bf8
0x00007ffeefbff428: 0x00000000047810a8 0x000000c000243bc8
0x00007ffeefbff438: 0x0000000004061670 <runtime.asmcgocall+0x0000000000000070> 0x00000000040181f5 <runtime.SetFinalizer.func2+0x0000000000000035>
0x00007ffeefbff448: 0x000000c0001aa6c0 0x0000000004130b78
0x00007ffeefbff458: 0x0000000000000010 0x000000000410c380
0x00007ffeefbff468: 0x0000000000000460 0x000000c0000001a0
0x00007ffeefbff478: 0x000000000405f789 <runtime.systemstack+0x0000000000000049> 0x0000000000000004
0x00007ffeefbff488: 0x000000000414faa0 0x000000000420dae0
0x00007ffeefbff498: 0x00007ffeefbff4e8 0x000000000405f685 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff4a8: 0x000000000405f63d <runtime.rt0_go+0x000000000000013d>
runtime.sigpanic()
/opt/local/lib/go/src/runtime/signal_unix.go:719 +0x396
goroutine 1 [syscall]:
syscall.syscall(0x40c1600, 0x3, 0x40487413, 0xc000243c88)
/opt/local/lib/go/src/runtime/sys_darwin.go:22 +0x3b fp=0xc000243bf8 sp=0xc000243bd8 pc=0x405e3bb
syscall.syscall(0xc000243c98, 0x40947be, 0x3, 0x412766a)
<autogenerated>:1 +0x26 fp=0xc000243c40 sp=0xc000243bf8 pc=0x4063f06
golang.org/x/sys/unix.ioctl(0x60, 0x42a4a68, 0x60)
/Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20210309074719-68d13333faf2/unix/zsyscall_darwin_amd64.go:690 +0x39 fp=0xc000243c70 sp=0xc000243c40 pc=0x40c1299
golang.org/x/sys/unix.IoctlGetTermios(...)
/Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20210309074719-68d13333faf2/unix/ioctl.go:73
golang.org/x/term.isTerminal(0x412766a)
/Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20210220032956-6a3ed077a48d/term_unix.go:19 +0x50 fp=0xc000243ce0 sp=0xc000243c70 pc=0x40c2330
golang.org/x/term.IsTerminal(...)
/Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20210220032956-6a3ed077a48d/term.go:24
github.com/gdamore/tcell/v2.NewDevTtyFromDev({0x412766a, 0x8})
/Users/ajm/go/pkg/mod/github.com/gdamore/tcell/v2@v2.4.1-0.20210905002822-f057f0a857a1/tty_unix.go:181 +0x10a fp=0xc000243d50 sp=0xc000243ce0 pc=0x40f75aa
github.com/gdamore/tcell/v2.NewDevTty(...)
/Users/ajm/go/pkg/mod/github.com/gdamore/tcell/v2@v2.4.1-0.20210905002822-f057f0a857a1/tty_unix.go:167
github.com/gdamore/tcell/v2.(*tScreen).initialize(0xc000194240)
/Users/ajm/go/pkg/mod/github.com/gdamore/tcell/v2@v2.4.1-0.20210905002822-f057f0a857a1/tscreen_unix.go:25 +0x31 fp=0xc000243d70 sp=0xc000243d50 pc=0x40f68b1
github.com/gdamore/tcell/v2.(*tScreen).Init(0xc000194240)
/Users/ajm/go/pkg/mod/github.com/gdamore/tcell/v2@v2.4.1-0.20210905002822-f057f0a857a1/tscreen.go:137 +0x25 fp=0xc000243de8 sp=0xc000243d70 pc=0x40e7f85
github.com/rivo/tview.(*Application).Run(0xc000248000)
/Users/ajm/go/pkg/mod/github.com/rivo/tview@v0.0.0-20211001102648-5508f4b00266/application.go:228 +0xb9 fp=0xc000243f48 sp=0xc000243de8 pc=0x40f7db9
main.main()
/Users/ajm/logger/repro/main.go:7 +0xbb fp=0xc000243f80 sp=0xc000243f48 pc=0x40fae3b
runtime.main()
/opt/local/lib/go/src/runtime/proc.go:255 +0x227 fp=0xc000243fe0 sp=0xc000243f80 pc=0x4034be7
runtime.goexit()
/opt/local/lib/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000243fe8 sp=0xc000243fe0 pc=0x4061961
exit status 2
Using cgo in a program that calls Application.Run() causes a crash.
Here's a simple repro:
I did a bisect and found that the crash started occurring with this commit: b2dec96. That commit upgrades tcell, so this may actually be more of a tcell issue. Not sure.
I'm on this go version:
Here's my error output: