Closed philrz closed 2 years ago
Looks like a Go 1.17 bug triggered by system calls through golang.org/x/sys/unix
when using cgo. (It affects zinger because github.com/confluentinc/confluent-kafka-go
uses cgo.)
$ uname -v
Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
$ go version
go version go1.17.1 darwin/amd64
$ cat main.go
package main
import "C"
import "golang.org/x/sys/unix"
func main() {
unix.CloseOnExec(0)
}
$ go run main.go
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff20440c9e]
runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff20440c9e
stack: frame={sp:0x7ffeefbff5c8, fp:0x7ffeefbff618} stack=[0x7ffeefb80668,0x7ffeefbff6d0)
0x00007ffeefbff4c8: 0x01007ffeefbff4e8 0x0000000000000004
0x00007ffeefbff4d8: 0x000000000000001f 0x00007fff20440c9e
0x00007ffeefbff4e8: 0x0b01dfacedebac1e 0x0000000000000001
0x00007ffeefbff4f8: 0x000000000402c571 <runtime.throw+0x0000000000000071> 0x00007ffeefbff598
0x00007ffeefbff508: 0x000000000406db60 0x00007ffeefbff550
0x00007ffeefbff518: 0x000000000402c828 <runtime.fatalthrow.func1+0x0000000000000048> 0x00000000040dbae0
0x00007ffeefbff528: 0x0000000000000001 0x0000000000000001
0x00007ffeefbff538: 0x00007ffeefbff598 0x000000000402c571 <runtime.throw+0x0000000000000071>
0x00007ffeefbff548: 0x00000000040dbae0 0x00007ffeefbff588
0x00007ffeefbff558: 0x000000000402c7b0 <runtime.fatalthrow+0x0000000000000050> 0x00007ffeefbff568
0x00007ffeefbff568: 0x000000000402c7e0 <runtime.fatalthrow.func1+0x0000000000000000> 0x00000000040dbae0
0x00007ffeefbff578: 0x000000000402c571 <runtime.throw+0x0000000000000071> 0x00007ffeefbff598
0x00007ffeefbff588: 0x00007ffeefbff5b8 0x000000000402c571 <runtime.throw+0x0000000000000071>
0x00007ffeefbff598: 0x00007ffeefbff5a0 0x000000000402c5a0 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff5a8: 0x000000000406efc5 0x000000000000002a
0x00007ffeefbff5b8: 0x00007ffeefbff608 0x000000000403ff56 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff5c8: <0x000000000406efc5 0x00007ffeefbff630
0x00007ffeefbff5d8: 0x00007ffeefbff648 0x0000000004020886 <runtime.(*mheap).allocSpan+0x0000000000000546>
0x00007ffeefbff5e8: 0x000000c0000ac000 0x0000000000002000
0x00007ffeefbff5f8: 0x000000c000000008 0x0000000000000000
0x00007ffeefbff608: 0x00007ffeefbff650 !0x00007fff20440c9e
0x00007ffeefbff618: >0x00007ffeefbff650 0x00000000040c8000
0x00007ffeefbff628: 0x0000000000000070 0x000000000405c145 <golang.org/x/sys/unix.libc_fcntl_trampoline+0x0000000000000005>
0x00007ffeefbff638: 0x000000000405585f <runtime.syscall+0x000000000000001f> 0x000000c000058ed8
0x00007ffeefbff648: 0x00007ffeefbff690 0x000000c000058ea8
0x00007ffeefbff658: 0x0000000004053750 <runtime.asmcgocall+0x0000000000000070> 0x0000000000000001
0x00007ffeefbff668: 0x000000c000080d00 0x0d007ffeefbff690
0x00007ffeefbff678: 0x0000000004036dc5 <runtime.malg.func1+0x0000000000000025> 0x000000c000008000
0x00007ffeefbff688: 0x0000000000000180 0x000000c0000001a0
0x00007ffeefbff698: 0x0000000004053529 <runtime.systemstack+0x0000000000000049> 0x0000000000000004
0x00007ffeefbff6a8: 0x0000000004080cf8 0x00000000040dbae0
0x00007ffeefbff6b8: 0x00007ffeefbff700 0x0000000004053425 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff6c8: 0x00000000040533dd <runtime.rt0_go+0x000000000000013d>
runtime.throw({0x406efc5, 0x7ffeefbff630})
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff20440c9e
stack: frame={sp:0x7ffeefbff5c8, fp:0x7ffeefbff618} stack=[0x7ffeefb80668,0x7ffeefbff6d0)
0x00007ffeefbff4c8: 0x01007ffeefbff4e8 0x0000000000000004
0x00007ffeefbff4d8: 0x000000000000001f 0x00007fff20440c9e
0x00007ffeefbff4e8: 0x0b01dfacedebac1e 0x0000000000000001
0x00007ffeefbff4f8: 0x000000000402c571 <runtime.throw+0x0000000000000071> 0x00007ffeefbff598
0x00007ffeefbff508: 0x000000000406db60 0x00007ffeefbff550
0x00007ffeefbff518: 0x000000000402c828 <runtime.fatalthrow.func1+0x0000000000000048> 0x00000000040dbae0
0x00007ffeefbff528: 0x0000000000000001 0x0000000000000001
0x00007ffeefbff538: 0x00007ffeefbff598 0x000000000402c571 <runtime.throw+0x0000000000000071>
0x00007ffeefbff548: 0x00000000040dbae0 0x00007ffeefbff588
0x00007ffeefbff558: 0x000000000402c7b0 <runtime.fatalthrow+0x0000000000000050> 0x00007ffeefbff568
0x00007ffeefbff568: 0x000000000402c7e0 <runtime.fatalthrow.func1+0x0000000000000000> 0x00000000040dbae0
0x00007ffeefbff578: 0x000000000402c571 <runtime.throw+0x0000000000000071> 0x00007ffeefbff598
0x00007ffeefbff588: 0x00007ffeefbff5b8 0x000000000402c571 <runtime.throw+0x0000000000000071>
0x00007ffeefbff598: 0x00007ffeefbff5a0 0x000000000402c5a0 <runtime.throw.func1+0x0000000000000000>
0x00007ffeefbff5a8: 0x000000000406efc5 0x000000000000002a
0x00007ffeefbff5b8: 0x00007ffeefbff608 0x000000000403ff56 <runtime.sigpanic+0x0000000000000396>
0x00007ffeefbff5c8: <0x000000000406efc5 0x00007ffeefbff630
0x00007ffeefbff5d8: 0x00007ffeefbff648 0x0000000004020886 <runtime.(*mheap).allocSpan+0x0000000000000546>
0x00007ffeefbff5e8: 0x000000c0000ac000 0x0000000000002000
0x00007ffeefbff5f8: 0x000000c000000008 0x0000000000000000
0x00007ffeefbff608: 0x00007ffeefbff650 !0x00007fff20440c9e
0x00007ffeefbff618: >0x00007ffeefbff650 0x00000000040c8000
0x00007ffeefbff628: 0x0000000000000070 0x000000000405c145 <golang.org/x/sys/unix.libc_fcntl_trampoline+0x0000000000000005>
0x00007ffeefbff638: 0x000000000405585f <runtime.syscall+0x000000000000001f> 0x000000c000058ed8
0x00007ffeefbff648: 0x00007ffeefbff690 0x000000c000058ea8
0x00007ffeefbff658: 0x0000000004053750 <runtime.asmcgocall+0x0000000000000070> 0x0000000000000001
0x00007ffeefbff668: 0x000000c000080d00 0x0d007ffeefbff690
0x00007ffeefbff678: 0x0000000004036dc5 <runtime.malg.func1+0x0000000000000025> 0x000000c000008000
0x00007ffeefbff688: 0x0000000000000180 0x000000c0000001a0
0x00007ffeefbff698: 0x0000000004053529 <runtime.systemstack+0x0000000000000049> 0x0000000000000004
0x00007ffeefbff6a8: 0x0000000004080cf8 0x00000000040dbae0
0x00007ffeefbff6b8: 0x00007ffeefbff700 0x0000000004053425 <runtime.mstart+0x0000000000000005>
0x00007ffeefbff6c8: 0x00000000040533dd <runtime.rt0_go+0x000000000000013d>
runtime.sigpanic()
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/signal_unix.go:719 +0x396
goroutine 1 [syscall]:
syscall.syscall(0x405c140, 0x0, 0x2, 0x1)
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/sys_darwin.go:22 +0x3b fp=0xc000058ed8 sp=0xc000058eb8 pc=0x405245b
syscall.syscall(0x200000003, 0xc0000001a0, 0xc000058f70, 0x4004e99)
<autogenerated>:1 +0x26 fp=0xc000058f20 sp=0xc000058ed8 pc=0x4055e26
golang.org/x/sys/unix.fcntl(0x0, 0x4060e20, 0xc0000001a0)
/Users/noah/looky/pkg/mod/golang.org/x/sys@v0.0.0-20210105210732-16f7687f5001/unix/zsyscall_darwin_amd64.go:660 +0x39 fp=0xc000058f58 sp=0xc000058f20 pc=0x405bdb9
golang.org/x/sys/unix.CloseOnExec(...)
/Users/noah/looky/pkg/mod/golang.org/x/sys@v0.0.0-20210105210732-16f7687f5001/unix/syscall_unix.go:388
main.main()
/Users/noah/looky/zinger/main.go:7 +0x25 fp=0xc000058f80 sp=0xc000058f58 pc=0x405c1c5
runtime.main()
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/proc.go:255 +0x227 fp=0xc000058fe0 sp=0xc000058f80 pc=0x402ec07
runtime.goexit()
/usr/local/Cellar/go/1.17.1/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x4053a21
exit status 2
This is fixed in Go 1.17.3. I can't reproduce this with Go 1.17.1 on macOS Monterey 12.0.1 (kernel 21.1.0).
After compiling/installing Zinger 16dc833 on my Mac, I tried to look at the current help text and saw the following crash.
I actually had seen a similar crash when attempting a
zinger consume
command line in thedust-off
branch before it merged. I assume they share a root cause, but if it can be triggered with justzinger -h
that seems the easy one to start with.@nwt and I had some back & forth trying to narrow down the root cause of this, and it looks like it's related to Go version:
It looks like the problem may be unique to macOS, though. I just compiled with Go 1.17.1 on a Linux Ubuntu 18.04 VM and
zinger -h
ran successfully without crashing.