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

using cgo causes crash on macos #492

Closed
amonks opened this issue Oct 6, 2021 · 13 comments
Closed

using cgo causes crash on macos #492

amonks opened this issue Oct 6, 2021 · 13 comments

Comments

@amonks
Copy link

amonks commented Oct 6, 2021

Using import "C" in a program which also uses tcell causes a crash on macos.

I am using this go version:

> go version
go version go1.17 darwin/amd64

To repro, I added the line import "C" to the example program in TUTORIAL.md. Here's a gist.

I did a bisect, and it reports this commit:

e9095fe4f117459e3d961ea4eb3f55bf8f45e91c is the first bad commit
commit e9095fe4f117459e3d961ea4eb3f55bf8f45e91c
Author: Garrett D'Amore <garrett@damore.org>
Date:   Sun Jan 24 13:26:36 2021 -0800

    fixes #394 Screen.Fini does not leave the terminal in a usable state in MacOS

    This does sort the main problem of screen.Fini(), but really we
    want to use a separate Pause() and Resume() function, because
    screen.Fini() is not meant for reuse in this way.

    Note that one side effect of this change is that applications which
    redirect stdin and stdout and expect us to just use /dev/tty instead
    are going to break -- we are now using stdin and stdout like nearly
    every other screen oriented application.

here is my stacktrace:

> go run repro/main.go
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:0x7ffeefbff658, fp:0x7ffeefbff6a8} stack=[0x7ffeefb806f8,0x7ffeefbff760)
0x00007ffeefbff558:  0x01007ffeefbff578  0x0000000000000004
0x00007ffeefbff568:  0x000000000000001f  0x00007fff2058acbe
0x00007ffeefbff578:  0x0b01dfacedebac1e  0x0000000000000001
0x00007ffeefbff588:  0x0000000004032d11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff628
0x00007ffeefbff598:  0x0000000004123dc5  0x00007ffeefbff5e0
0x00007ffeefbff5a8:  0x0000000004032fc8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000041fe280
0x00007ffeefbff5b8:  0x0000000000000001  0x0000000000000001
0x00007ffeefbff5c8:  0x00007ffeefbff628  0x0000000004032d11 <runtime.throw+0x0000000000000071>
0x00007ffeefbff5d8:  0x00000000041fe280  0x00007ffeefbff618
0x00007ffeefbff5e8:  0x0000000004032f50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff5f8
0x00007ffeefbff5f8:  0x0000000004032f80 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000041fe280
0x00007ffeefbff608:  0x0000000004032d11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff628
0x00007ffeefbff618:  0x00007ffeefbff648  0x0000000004032d11 <runtime.throw+0x0000000000000071>
0x00007ffeefbff628:  0x00007ffeefbff630  0x0000000004032d40 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff638:  0x0000000004125e5a  0x000000000000002a
0x00007ffeefbff648:  0x00007ffeefbff698  0x0000000004048836 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff658: <0x0000000004125e5a  0x000000c000057140
0x00007ffeefbff668:  0x000000c000057138  0x00007ffeefbff6d0
0x00007ffeefbff678:  0x00007fff2056fe13  0x0000000000000000
0x00007ffeefbff688:  0x0000000000000000  0x000000c000057120
0x00007ffeefbff698:  0x00007ffeefbff6e0 !0x00007fff2058acbe
0x00007ffeefbff6a8: >0x00007ffeefbff6e0  0x00000000041e0000
0x00007ffeefbff6b8:  0x0000000000000129  0x00000000040e3145 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff6c8:  0x00000000040638df <runtime.syscall+0x000000000000001f>  0x000000c0000c9cb0
0x00007ffeefbff6d8:  0x00000000040637ec <runtime.pthread_mutex_unlock_trampoline+0x000000000000000c>  0x000000c0000c9c80
0x00007ffeefbff6e8:  0x0000000004061770 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000001
0x00007ffeefbff6f8:  0x0000000004002200 <sync/atomic.(*Value).Store+0x0000000000000060>  0x2200000000001018
0x00007ffeefbff708:  0x0000000000000010  0x000000000422e4d8
0x00007ffeefbff718:  0x00000000000003a8  0x000000c0000001a0
0x00007ffeefbff728:  0x000000000405f889 <runtime.systemstack+0x0000000000000049>  0x0000000000000004
0x00007ffeefbff738:  0x0000000004146070  0x00000000041fe280
0x00007ffeefbff748:  0x00007ffeefbff798  0x000000000405f785 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff758:  0x000000000405f73d <runtime.rt0_go+0x000000000000013d>
runtime.throw({0x4125e5a, 0xc000057140})
        /opt/local/lib/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff2058acbe
stack: frame={sp:0x7ffeefbff658, fp:0x7ffeefbff6a8} stack=[0x7ffeefb806f8,0x7ffeefbff760)
0x00007ffeefbff558:  0x01007ffeefbff578  0x0000000000000004
0x00007ffeefbff568:  0x000000000000001f  0x00007fff2058acbe
0x00007ffeefbff578:  0x0b01dfacedebac1e  0x0000000000000001
0x00007ffeefbff588:  0x0000000004032d11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff628
0x00007ffeefbff598:  0x0000000004123dc5  0x00007ffeefbff5e0
0x00007ffeefbff5a8:  0x0000000004032fc8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000041fe280
0x00007ffeefbff5b8:  0x0000000000000001  0x0000000000000001
0x00007ffeefbff5c8:  0x00007ffeefbff628  0x0000000004032d11 <runtime.throw+0x0000000000000071>
0x00007ffeefbff5d8:  0x00000000041fe280  0x00007ffeefbff618
0x00007ffeefbff5e8:  0x0000000004032f50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff5f8
0x00007ffeefbff5f8:  0x0000000004032f80 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000041fe280
0x00007ffeefbff608:  0x0000000004032d11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff628
0x00007ffeefbff618:  0x00007ffeefbff648  0x0000000004032d11 <runtime.throw+0x0000000000000071>
0x00007ffeefbff628:  0x00007ffeefbff630  0x0000000004032d40 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff638:  0x0000000004125e5a  0x000000000000002a
0x00007ffeefbff648:  0x00007ffeefbff698  0x0000000004048836 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff658: <0x0000000004125e5a  0x000000c000057140
0x00007ffeefbff668:  0x000000c000057138  0x00007ffeefbff6d0
0x00007ffeefbff678:  0x00007fff2056fe13  0x0000000000000000
0x00007ffeefbff688:  0x0000000000000000  0x000000c000057120
0x00007ffeefbff698:  0x00007ffeefbff6e0 !0x00007fff2058acbe
0x00007ffeefbff6a8: >0x00007ffeefbff6e0  0x00000000041e0000
0x00007ffeefbff6b8:  0x0000000000000129  0x00000000040e3145 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff6c8:  0x00000000040638df <runtime.syscall+0x000000000000001f>  0x000000c0000c9cb0
0x00007ffeefbff6d8:  0x00000000040637ec <runtime.pthread_mutex_unlock_trampoline+0x000000000000000c>  0x000000c0000c9c80
0x00007ffeefbff6e8:  0x0000000004061770 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000001
0x00007ffeefbff6f8:  0x0000000004002200 <sync/atomic.(*Value).Store+0x0000000000000060>  0x2200000000001018
0x00007ffeefbff708:  0x0000000000000010  0x000000000422e4d8
0x00007ffeefbff718:  0x00000000000003a8  0x000000c0000001a0
0x00007ffeefbff728:  0x000000000405f889 <runtime.systemstack+0x0000000000000049>  0x0000000000000004
0x00007ffeefbff738:  0x0000000004146070  0x00000000041fe280
0x00007ffeefbff748:  0x00007ffeefbff798  0x000000000405f785 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff758:  0x000000000405f73d <runtime.rt0_go+0x000000000000013d>
runtime.sigpanic()
        /opt/local/lib/go/src/runtime/signal_unix.go:719 +0x396

goroutine 1 [syscall]:
syscall.syscall(0x40e3140, 0x0, 0x40487413, 0xc0000c9d40)
        /opt/local/lib/go/src/runtime/sys_darwin.go:22 +0x3b fp=0xc0000c9cb0 sp=0xc0000c9c90 pc=0x405e4bb
syscall.syscall(0x30, 0x41fe800, 0xc00009c6c0, 0x0)
        <autogenerated>:1 +0x26 fp=0xc0000c9cf8 sp=0xc0000c9cb0 pc=0x4064006
golang.org/x/sys/unix.ioctl(0x400e207, 0x30, 0x410f500)
        /Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20201119102817-f84b799fce68/unix/zsyscall_darwin_amd64.go:731 +0x39 fp=0xc0000c9d28 sp=0xc0000c9cf8 pc=0x40e2dd9
golang.org/x/sys/unix.IoctlGetTermios(...)
        /Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20201119102817-f84b799fce68/unix/ioctl.go:72
golang.org/x/term.getState(0x40682e0)
        /Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20201210144234-2321bbc49cbf/term_unix.go:47 +0x54 fp=0xc0000c9d98 sp=0xc0000c9d28 pc=0x40e3434
golang.org/x/term.GetState(...)
        /Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20201210144234-2321bbc49cbf/term.go:37
github.com/gdamore/tcell/v2.(*tScreen).initialize(0xc00013a000)
        /Users/ajm/tcell/tscreen_unix.go:60 +0xa5 fp=0xc0000c9de0 sp=0xc0000c9d98 pc=0x40f39c5
github.com/gdamore/tcell/v2.(*tScreen).Init(0xc00013a000)
        /Users/ajm/tcell/tscreen.go:149 +0x27c fp=0xc0000c9e68 sp=0xc0000c9de0 pc=0x40e5abc
main.main()
        /Users/ajm/tcell/repro/main.go:74 +0xae fp=0xc0000c9f80 sp=0xc0000c9e68 pc=0x40f496e
runtime.main()
        /opt/local/lib/go/src/runtime/proc.go:255 +0x227 fp=0xc0000c9fe0 sp=0xc0000c9f80 pc=0x40353a7
runtime.goexit()
        /opt/local/lib/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc0000c9fe8 sp=0xc0000c9fe0 pc=0x4061a61
exit status 2
@gdamore
Copy link
Owner

gdamore commented Oct 11, 2021

This is rather bizarre. Do you have a very simple reproducer program?

@amonks
Copy link
Author

amonks commented Oct 11, 2021

I do!

I'm not too familiar with tcell (I use it via tview), so, to reproduce, I added the line import "C" to the example program in TUTORIAL.md. Here's that program as a gist.

The only differences from what's in TUTORIAL.md are,

  • I added import "C" on line 3
  • I commented s.EnablePaste() on line 79 to help with a git bisect (it looks like EnablePaste is a newer feature than my bisect-start)

@gdamore
Copy link
Owner

gdamore commented Oct 12, 2021

This problem does not reproduce for me. I am using go 1.17.2 on M1 (macOS Big Sur). I am also using clang 13.0 (from Xcode).

My guess is that there is something wrong in your tool chain and that is what is breaking - probably something is not getting linked correctly.

Maybe try updating go, and Xcode and seeing if that helps. Make sure that there aren't any other versions of gcc or anything like that in your PATH that might conflict.

@gdamore
Copy link
Owner

gdamore commented Oct 12, 2021

It also looks like you have a locally built version of go. I just installed the normal go from the go website using the macOS installer.

@amonks
Copy link
Author

amonks commented Oct 12, 2021

I upgraded go, and verified that I'm on latest Xcode and stock gcc/clang, but I still get the crash.

Here are more facts about my system:

  • I was previously using go from macports. I uninstalled that and installed via the .pkg on golang.org. My go version is now go version go1.17.2 darwin/amd64.
  • I ran go clean -cache -modcache.
  • I have Xcode 13 installed. (Maybe that's it? 13's very new)
  • I'm on x86_64, macOS Big Sur.

c compiler info:

> clang --version
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
> gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

here is a stacktrace from after all that:

> go run ./repro
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/gdamore/encoding v1.0.0
go: downloading github.com/mattn/go-runewidth v0.0.13
go: downloading golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
go: downloading golang.org/x/text v0.3.7
go: downloading golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
go: downloading github.com/rivo/uniseg v0.2.0
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff204d4cbe]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff204d4cbe
stack: frame={sp:0x7ffeefbff608, fp:0x7ffeefbff658} stack=[0x7ffeefb806a8,0x7ffeefbff710)
0x00007ffeefbff508:  0x01007ffeefbff528  0x0000000000000004
0x00007ffeefbff518:  0x000000000000001f  0x00007fff204d4cbe
0x00007ffeefbff528:  0x0b01dfacedebac1e  0x0000000000000001
0x00007ffeefbff538:  0x0000000004033811 <runtime.throw+0x0000000000000071>  0x00007ffeefbff5d8
0x00007ffeefbff548:  0x000000000412b540  0x00007ffeefbff590
0x00007ffeefbff558:  0x0000000004033ac8 <runtime.fatalthrow.func1+0x0000000000000048>  0x000000000420a700
0x00007ffeefbff568:  0x0000000000000001  0x0000000000000001
0x00007ffeefbff578:  0x00007ffeefbff5d8  0x0000000004033811 <runtime.throw+0x0000000000000071>
0x00007ffeefbff588:  0x000000000420a700  0x00007ffeefbff5c8
0x00007ffeefbff598:  0x0000000004033a50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff5a8
0x00007ffeefbff5a8:  0x0000000004033a80 <runtime.fatalthrow.func1+0x0000000000000000>  0x000000000420a700
0x00007ffeefbff5b8:  0x0000000004033811 <runtime.throw+0x0000000000000071>  0x00007ffeefbff5d8
0x00007ffeefbff5c8:  0x00007ffeefbff5f8  0x0000000004033811 <runtime.throw+0x0000000000000071>
0x00007ffeefbff5d8:  0x00007ffeefbff5e0  0x0000000004033840 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff5e8:  0x000000000412d68c  0x000000000000002a
0x00007ffeefbff5f8:  0x00007ffeefbff648  0x0000000004049336 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff608: <0x000000000412d68c  0x000000000420a700
0x00007ffeefbff618:  0x01007ffeefbff688  0x00000000042ab8e0
0x00007ffeefbff628:  0x0000000000000240  0x000000000420ac80
0x00007ffeefbff638:  0x00000000042ab958  0x00007ffeefbff698
0x00007ffeefbff648:  0x00007ffeefbff690 !0x00007fff204d4cbe
0x00007ffeefbff658: >0x00007ffeefbff690  0x00000000041ec000
0x00007ffeefbff668:  0x0000000000000129  0x00000000040c28a5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff678:  0x0000000004064abf <runtime.syscall+0x000000000000001f>  0x000000c00012fc78
0x00007ffeefbff688:  0x00000000047728f8  0x000000c00012fc48
0x00007ffeefbff698:  0x0000000004062950 <runtime.asmcgocall+0x0000000000000070>  0x00000000040194b5 <runtime.SetFinalizer.func2+0x0000000000000035>
0x00007ffeefbff6a8:  0x000000c00007c240  0x000000000412f698
0x00007ffeefbff6b8:  0x0000000000000010  0x000000000410b700
0x00007ffeefbff6c8:  0x00000000000003e0  0x000000c0000001a0
0x00007ffeefbff6d8:  0x0000000004060a69 <runtime.systemstack+0x0000000000000049>  0x0000000000000004
0x00007ffeefbff6e8:  0x000000000414e558  0x000000000420a700
0x00007ffeefbff6f8:  0x00007ffeefbff740  0x0000000004060965 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff708:  0x000000000406091d <runtime.rt0_go+0x000000000000013d>
runtime.throw({0x412d68c, 0x420a700})
        /usr/local/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff204d4cbe
stack: frame={sp:0x7ffeefbff608, fp:0x7ffeefbff658} stack=[0x7ffeefb806a8,0x7ffeefbff710)
0x00007ffeefbff508:  0x01007ffeefbff528  0x0000000000000004
0x00007ffeefbff518:  0x000000000000001f  0x00007fff204d4cbe
0x00007ffeefbff528:  0x0b01dfacedebac1e  0x0000000000000001
0x00007ffeefbff538:  0x0000000004033811 <runtime.throw+0x0000000000000071>  0x00007ffeefbff5d8
0x00007ffeefbff548:  0x000000000412b540  0x00007ffeefbff590
0x00007ffeefbff558:  0x0000000004033ac8 <runtime.fatalthrow.func1+0x0000000000000048>  0x000000000420a700
0x00007ffeefbff568:  0x0000000000000001  0x0000000000000001
0x00007ffeefbff578:  0x00007ffeefbff5d8  0x0000000004033811 <runtime.throw+0x0000000000000071>
0x00007ffeefbff588:  0x000000000420a700  0x00007ffeefbff5c8
0x00007ffeefbff598:  0x0000000004033a50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff5a8
0x00007ffeefbff5a8:  0x0000000004033a80 <runtime.fatalthrow.func1+0x0000000000000000>  0x000000000420a700
0x00007ffeefbff5b8:  0x0000000004033811 <runtime.throw+0x0000000000000071>  0x00007ffeefbff5d8
0x00007ffeefbff5c8:  0x00007ffeefbff5f8  0x0000000004033811 <runtime.throw+0x0000000000000071>
0x00007ffeefbff5d8:  0x00007ffeefbff5e0  0x0000000004033840 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff5e8:  0x000000000412d68c  0x000000000000002a
0x00007ffeefbff5f8:  0x00007ffeefbff648  0x0000000004049336 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff608: <0x000000000412d68c  0x000000000420a700
0x00007ffeefbff618:  0x01007ffeefbff688  0x00000000042ab8e0
0x00007ffeefbff628:  0x0000000000000240  0x000000000420ac80
0x00007ffeefbff638:  0x00000000042ab958  0x00007ffeefbff698
0x00007ffeefbff648:  0x00007ffeefbff690 !0x00007fff204d4cbe
0x00007ffeefbff658: >0x00007ffeefbff690  0x00000000041ec000
0x00007ffeefbff668:  0x0000000000000129  0x00000000040c28a5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005>
0x00007ffeefbff678:  0x0000000004064abf <runtime.syscall+0x000000000000001f>  0x000000c00012fc78
0x00007ffeefbff688:  0x00000000047728f8  0x000000c00012fc48
0x00007ffeefbff698:  0x0000000004062950 <runtime.asmcgocall+0x0000000000000070>  0x00000000040194b5 <runtime.SetFinalizer.func2+0x0000000000000035>
0x00007ffeefbff6a8:  0x000000c00007c240  0x000000000412f698
0x00007ffeefbff6b8:  0x0000000000000010  0x000000000410b700
0x00007ffeefbff6c8:  0x00000000000003e0  0x000000c0000001a0
0x00007ffeefbff6d8:  0x0000000004060a69 <runtime.systemstack+0x0000000000000049>  0x0000000000000004
0x00007ffeefbff6e8:  0x000000000414e558  0x000000000420a700
0x00007ffeefbff6f8:  0x00007ffeefbff740  0x0000000004060965 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff708:  0x000000000406091d <runtime.rt0_go+0x000000000000013d>
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:719 +0x396

goroutine 1 [syscall]:
syscall.syscall(0x40c28a0, 0x3, 0x40487413, 0xc00012fd08)
        /usr/local/go/src/runtime/sys_darwin.go:22 +0x3b fp=0xc00012fc78 sp=0xc00012fc58 pc=0x405f69b
syscall.syscall(0xc00012fd18, 0x409229e, 0x3, 0x4126350)
        <autogenerated>:1 +0x26 fp=0xc00012fcc0 sp=0xc00012fc78 pc=0x40651e6
golang.org/x/sys/unix.ioctl(0x60, 0x42a0108, 0x60)
        /Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20201119102817-f84b799fce68/unix/zsyscall_darwin_amd64.go:731 +0x39 fp=0xc00012fcf0 sp=0xc00012fcc0 pc=0x40c2539
golang.org/x/sys/unix.IoctlGetTermios(...)
        /Users/ajm/go/pkg/mod/golang.org/x/sys@v0.0.0-20201119102817-f84b799fce68/unix/ioctl.go:72
golang.org/x/term.isTerminal(0x4126350)
        /Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20201210144234-2321bbc49cbf/term_unix.go:18 +0x50 fp=0xc00012fd60 sp=0xc00012fcf0 pc=0x40c35d0
golang.org/x/term.IsTerminal(...)
        /Users/ajm/go/pkg/mod/golang.org/x/term@v0.0.0-20201210144234-2321bbc49cbf/term.go:24
github.com/gdamore/tcell/v2.NewDevTtyFromDev({0x4126350, 0x8})
        /Users/ajm/tcell/tty_unix.go:180 +0x10a fp=0xc00012fdd0 sp=0xc00012fd60 pc=0x40f932a
github.com/gdamore/tcell/v2.NewDevTty(...)
        /Users/ajm/tcell/tty_unix.go:166
github.com/gdamore/tcell/v2.(*tScreen).initialize(0xc000194000)
        /Users/ajm/tcell/tscreen_unix.go:25 +0x31 fp=0xc00012fdf0 sp=0xc00012fdd0 pc=0x40f86b1
github.com/gdamore/tcell/v2.(*tScreen).Init(0xc000194000)
        /Users/ajm/tcell/tscreen.go:164 +0x25 fp=0xc00012fe68 sp=0xc00012fdf0 pc=0x40e94a5
main.main()
        /Users/ajm/tcell/repro/main.go:74 +0xae fp=0xc00012ff80 sp=0xc00012fe68 pc=0x40fa26e
runtime.main()
        /usr/local/go/src/runtime/proc.go:255 +0x227 fp=0xc00012ffe0 sp=0xc00012ff80 pc=0x4035ea7
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00012ffe8 sp=0xc00012ffe0 pc=0x4062c41
exit status 2

@gdamore
Copy link
Owner

gdamore commented Oct 12, 2021

I didn't have a gcc on my path. But I do have clang. Other than that the only difference is arm64 vs x86_64.

The fact that cgo makes a difference makes me feel very much this is a tool chain problem.

@aarock1234
Copy link

aarock1234 commented Oct 17, 2021

I am having the same issue stated here.

OS:
Big Sur 11.6

Hardware:
MacBook Pro (15-inch, 2017)
2.9 GHz Quad-Core Intel Core i7

@gdamore
Copy link
Owner

gdamore commented Oct 17, 2021

This is strange. I cannot think of any good reason for this to occur apart from a bug in the runtime or tool chain. It works fine on M1 and I'm no longer in possession of an Intel Mac. If I have a little time I'll see if I can cross build and test with Rosetta.

It would be instructive to test this on an earlier version of macOS and Xcode.

@aarock1234
Copy link

This is strange. I cannot think of any good reason for this to occur apart from a bug in the runtime or tool chain. It works fine on M1 and I'm no longer in possession of an Intel Mac. If I have a little time I'll see if I can cross build and test with Rosetta.

It would be instructive to test this on an earlier version of macOS and Xcode.

Well, in the original issue made on the tview repo, by the same OP as this issue, he mentions specifically:

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.

Can we look into what has changed? If it is a "toolchain" issue is there any way to fix this? I reinstalled XCode and more, nothing changes.

@aarock1234
Copy link

NOTE:

I got the error to disappear with modifying the version of "golang.org/x/sys". BUT the go module "github.com/sqweek/dialog" I am using still is not working on the Mac system. Obviously not a tcell issue. I think this issue can be closed.

@gdamore
Copy link
Owner

gdamore commented Oct 21, 2021

What version of golang.org/x/sys worked for you?

@aarock1234
Copy link

What version of golang.org/x/sys worked for you?

golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect

@arnodel
Copy link

arnodel commented Jan 23, 2022

Hello, I just hit this issue when upgrading to tcell 2.4.0 (from 1.3) in a program that uses the "plugin" package.

For reference, I can reproduce the panic with this minimal program

package main

import "golang.org/x/sys/unix"

import "C"

func main() {
	unix.IoctlGetTermios(0, unix.TIOCGETA) // The syscall tcell makes when initializing
}

So the bug is definitely unrelated to tcell. Upgrading golang.org/x/sys/unix to the latest fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants