Assertion failed: (pthread_mutex_lock(mutex) == 0), function usbi_mutex_lock, file threads_posix.h, line 46.
SIGABRT: abort
PC=0x1c46acdb8 m=3 sigcode=0
signal arrived during cgo execution
goroutine 73 [syscall]:
runtime.cgocall(0x103279eac, 0x140001c9288)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/cgocall.go:157 +0x54 fp=0x140001c9250 sp=0x140001c9210 pc=0x102f67994
github.com/trezor/trezord-go/usb/lowlevel/libusb._Cfunc_libusb_cancel_sync_transfers_on_device(0x150008000)
_cgo_gotypes.go:580 +0x38 fp=0x140001c9280 sp=0x140001c9250 pc=0x103261b68
github.com/trezor/trezord-go/usb/lowlevel/libusb.Cancel_Sync_Transfers_On_Device.func1(0x1035be6e0?)
/Users/matejcik/projekty/prace/trezord-go/usb/lowlevel/libusb/libusb.go:1438 +0x44 fp=0x140001c92c0 sp=0x140001c9280 pc=0x1032646e4
github.com/trezor/trezord-go/usb/lowlevel/libusb.Cancel_Sync_Transfers_On_Device(0x1033f3d09?)
/Users/matejcik/projekty/prace/trezord-go/usb/lowlevel/libusb/libusb.go:1438 +0x20 fp=0x140001c92e0 sp=0x140001c92c0 pc=0x103264680
github.com/trezor/trezord-go/usb.(*LibUSBDevice).Close(0x140001b9940, 0x0)
/Users/matejcik/projekty/prace/trezord-go/usb/libusb.go:445 +0x74 fp=0x140001c9330 sp=0x140001c92e0 pc=0x1032679e4
github.com/trezor/trezord-go/core.(*Core).release(0x140000b4b60, {0x140001dc09e, 0x1}, 0x7?, 0x0)
/Users/matejcik/projekty/prace/trezord-go/core/core.go:369 +0x13c fp=0x140001c93c0 sp=0x140001c9330 pc=0x10305aa0c
github.com/trezor/trezord-go/core.(*Core).Release(...)
/Users/matejcik/projekty/prace/trezord-go/core/core.go:351
github.com/trezor/trezord-go/server/api.(*api).release(0x14000090c60, {0x1033cf118?, 0x14000110140}, 0x10324bf08?, 0x8?)
/Users/matejcik/projekty/prace/trezord-go/server/api/api.go:159 +0x90 fp=0x140001c9470 sp=0x140001c93c0 pc=0x1031f2bb0
github.com/trezor/trezord-go/server/api.(*api).Release(0x14000058901?, {0x1033cf118?, 0x14000110140?}, 0x0?)
/Users/matejcik/projekty/prace/trezord-go/server/api/api.go:146 +0x2c fp=0x140001c94b0 sp=0x140001c9470 pc=0x1031f2a6c
github.com/trezor/trezord-go/server/api.(*api).Release-fm({0x1033cf118?, 0x14000110140?}, 0x14000110001?)
<autogenerated>:1 +0x44 fp=0x140001c94e0 sp=0x140001c94b0 pc=0x1031f3d64
net/http.HandlerFunc.ServeHTTP(0x10339d600?, {0x1033cf118?, 0x14000110140?}, 0x1b?)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2084 +0x3c fp=0x140001c9510 sp=0x140001c94e0 pc=0x1031a57fc
github.com/trezor/trezord-go/server/api.(*cors).ServeHTTP(0x1400000e018, {0x1033cf118, 0x14000110140}, 0x1400021a200)
/Users/matejcik/projekty/prace/trezord-go/server/api/cors.go:69 +0x26c fp=0x140001c95d0 sp=0x140001c9510 pc=0x1031f391c
github.com/gorilla/mux.(*Router).ServeHTTP(0x140000f0000, {0x1033cf118, 0x14000110140}, 0x1400021a000)
/Users/matejcik/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1a0 fp=0x140001c9700 sp=0x140001c95d0 pc=0x1031e9440
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0x1033cc788, 0x140000a80a8}, {0x1033cc608, 0x140000f0000}, 0x1033ca4b8}, {0x1033ceba8, 0x140001180e0}, 0x1400021a000)
/Users/matejcik/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xa0 fp=0x140001c9950 sp=0x140001c9700 pc=0x10325d180
github.com/gorilla/handlers.(*loggingHandler).ServeHTTP(0x1032819c0?, {0x1033ceba8?, 0x140001180e0?}, 0x10?)
<autogenerated>:1 +0x7c fp=0x140001c99d0 sp=0x140001c9950 pc=0x10325ea6c
github.com/trezor/trezord-go/server.(*Server).logRequest.func1({0x1033ceba8, 0x140001180e0}, 0x1400021a000)
/Users/matejcik/projekty/prace/trezord-go/server/http.go:80 +0x138 fp=0x140001c9a50 sp=0x140001c99d0 pc=0x10325f408
net/http.HandlerFunc.ServeHTTP(0x0?, {0x1033ceba8?, 0x140001180e0?}, 0x102fa23ac?)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2084 +0x3c fp=0x140001c9a80 sp=0x140001c9a50 pc=0x1031a57fc
net/http.serverHandler.ServeHTTP({0x140004aac90?}, {0x1033ceba8, 0x140001180e0}, 0x1400021a000)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2916 +0x3fc fp=0x140001c9b40 sp=0x140001c9a80 pc=0x1031a89bc
net/http.(*conn).serve(0x140004c0000, {0x1033cf460, 0x140004aa930})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:1966 +0x56c fp=0x140001c9fa0 sp=0x140001c9b40 pc=0x1031a453c
net/http.(*Server).Serve.func3()
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:3071 +0x34 fp=0x140001c9fd0 sp=0x140001c9fa0 pc=0x1031a9204
runtime.goexit()
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/asm_arm64.s:1263 +0x4 fp=0x140001c9fd0 sp=0x140001c9fd0 pc=0x102fc69f4
created by net/http.(*Server).Serve
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:3071 +0x450
goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x12a5ef898, 0x72)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x140000a6400?, 0x4?, 0x0)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Accept(0x140000a6400)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_unix.go:614 +0x1d0
net.(*netFD).accept(0x140000a6400)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/fd_unix.go:172 +0x28
net.(*TCPListener).accept(0x140000a8138)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/tcpsock_posix.go:139 +0x2c
net.(*TCPListener).Accept(0x140000a8138)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/tcpsock.go:288 +0x30
net/http.(*Server).Serve(0x140000ee000, {0x1033ce9c8, 0x140000a8138})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:3039 +0x318
net/http.(*Server).ListenAndServe(0x140000ee000)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2968 +0x88
github.com/trezor/trezord-go/server.(*Server).Run(...)
/Users/matejcik/projekty/prace/trezord-go/server/http.go:85
main.main()
/Users/matejcik/projekty/prace/trezord-go/trezord.go:211 +0x924
goroutine 34 [chan receive]:
gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun(0x1400008e420)
/Users/matejcik/go/pkg/mod/gopkg.in/natefinch/lumberjack.v2@v2.0.0/lumberjack.go:379 +0x48
created by gopkg.in/natefinch/lumberjack%2ev2.(*Logger).mill.func1
/Users/matejcik/go/pkg/mod/gopkg.in/natefinch/lumberjack.v2@v2.0.0/lumberjack.go:390 +0xa8
goroutine 35 [sleep]:
time.Sleep(0x1dcd6500)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/time.go:194 +0x11c
github.com/trezor/trezord-go/core.(*Core).backgroundListen(0x140000b4b60)
/Users/matejcik/projekty/prace/trezord-go/core/core.go:178 +0x2c
created by github.com/trezor/trezord-go/core.New
/Users/matejcik/projekty/prace/trezord-go/core/core.go:160 +0x104
goroutine 36 [syscall]:
github.com/trezor/trezord-go/usb/lowlevel/libusb._Cfunc_libusb_interrupt_transfer(0x150008000, 0x81, 0x140001aef80, 0x40, 0x140001b5168, 0x0)
_cgo_gotypes.go:1196 +0x3c
github.com/trezor/trezord-go/usb/lowlevel/libusb.Interrupt_Transfer.func1(0x1035be790?, 0x20?, {0x140001aef80, 0x40, 0x10342ffd0?}, 0x3a?, 0x0)
/Users/matejcik/projekty/prace/trezord-go/usb/lowlevel/libusb/libusb.go:1429 +0x8c
github.com/trezor/trezord-go/usb/lowlevel/libusb.Interrupt_Transfer(0x1035be898?, 0x84?, {0x140001aef80, 0x40, 0x40}, 0x35?)
/Users/matejcik/projekty/prace/trezord-go/usb/lowlevel/libusb/libusb.go:1429 +0x64
github.com/trezor/trezord-go/usb.(*LibUSBDevice).readWrite(0x140001b9940, {0x140001aef80, 0x40, 0x40}, 0x40?, {0x1033ce318, 0x140001b994c})
/Users/matejcik/projekty/prace/trezord-go/usb/libusb.go:517 +0xe0
github.com/trezor/trezord-go/usb.(*LibUSBDevice).Read(0x140001b9940, {0x140001aef80, 0x40, 0x40})
/Users/matejcik/projekty/prace/trezord-go/usb/libusb.go:576 +0x90
github.com/trezor/trezord-go/wire.ReadFrom({0x12a7b6f18, 0x140001b9940}, 0x140000a6100)
/Users/matejcik/projekty/prace/trezord-go/wire/v1.go:81 +0x68
github.com/trezor/trezord-go/core.(*Core).readDev(0x140000b4b60, {0x12a7b6f18, 0x140001b9940})
/Users/matejcik/projekty/prace/trezord-go/core/core.go:620 +0x54
github.com/trezor/trezord-go/core.(*Core).readWriteDev(0x140000b4b60, {0x0?, 0x13?, 0x103045d14?}, 0x1400018e4b0, 0x0)
/Users/matejcik/projekty/prace/trezord-go/core/core.go:655 +0x2ac
github.com/trezor/trezord-go/core.(*Core).Call(0x140000b4b60, {0x0, 0x0, 0x0}, {0x1400002d7ab, 0x1}, 0x0, 0x0, {0x1033cf460?, 0x140004aaba0})
/Users/matejcik/projekty/prace/trezord-go/core/core.go:600 +0x400
github.com/trezor/trezord-go/server/api.(*api).call(0x14000090c60, {0x1033cf118, 0x140000c42d0}, 0x14000108900, 0x0, 0x7c?)
/Users/matejcik/projekty/prace/trezord-go/server/api/api.go:215 +0x170
github.com/trezor/trezord-go/server/api.(*api).Read(0x14000080001?, {0x1033cf118?, 0x140000c42d0?}, 0x0?)
/Users/matejcik/projekty/prace/trezord-go/server/api/api.go:180 +0x30
net/http.HandlerFunc.ServeHTTP(0x10339d600?, {0x1033cf118?, 0x140000c42d0?}, 0x1b?)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2084 +0x3c
github.com/trezor/trezord-go/server/api.(*cors).ServeHTTP(0x140000a8228, {0x1033cf118, 0x140000c42d0}, 0x14000108900)
/Users/matejcik/projekty/prace/trezord-go/server/api/cors.go:69 +0x26c
github.com/gorilla/mux.(*Router).ServeHTTP(0x140000f0000, {0x1033cf118, 0x140000c42d0}, 0x14000108700)
/Users/matejcik/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1a0
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0x1033cc788, 0x140000a80a8}, {0x1033cc608, 0x140000f0000}, 0x1033ca4b8}, {0x1033ceba8, 0x140000ee2a0}, 0x14000108700)
/Users/matejcik/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xa0
github.com/trezor/trezord-go/server.(*Server).logRequest.func1({0x1033ceba8, 0x140000ee2a0}, 0x14000108700)
/Users/matejcik/projekty/prace/trezord-go/server/http.go:80 +0x138
net/http.HandlerFunc.ServeHTTP(0x0?, {0x1033ceba8?, 0x140000ee2a0?}, 0x102fa23ac?)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2084 +0x3c
net/http.serverHandler.ServeHTTP({0x140004aaa20?}, {0x1033ceba8, 0x140000ee2a0}, 0x14000108700)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:2916 +0x3fc
net/http.(*conn).serve(0x140004c0140, {0x1033cf460, 0x140004aa930})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:1966 +0x56c
created by net/http.(*Server).Serve
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:3071 +0x450
goroutine 71 [IO wait]:
internal/poll.runtime_pollWait(0x12a5ef7a8, 0x72)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x140000a6480?, 0x140004aaa31?, 0x0)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0x140000a6480, {0x140004aaa31, 0x1, 0x1})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_unix.go:167 +0x1e4
net.(*netFD).Read(0x140000a6480, {0x140004aaa31?, 0x140000e7f48?, 0x10319ebdc?})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/fd_posix.go:55 +0x2c
net.(*conn).Read(0x1400009c238, {0x140004aaa31?, 0x140000c4230?, 0x0?})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/net.go:183 +0x38
net/http.(*connReader).backgroundRead(0x140004aaa20)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:672 +0x48
created by net/http.(*connReader).startBackgroundRead
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:668 +0xd0
goroutine 39 [IO wait]:
internal/poll.runtime_pollWait(0x12a5ef6b8, 0x72)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x140000a6280?, 0x140004aaca1?, 0x0)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0x140000a6280, {0x140004aaca1, 0x1, 0x1})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/internal/poll/fd_unix.go:167 +0x1e4
net.(*netFD).Read(0x140000a6280, {0x140004aaca1?, 0x0?, 0x102fc69f4?})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/fd_posix.go:55 +0x2c
net.(*conn).Read(0x1400009c050, {0x140004aaca1?, 0x1033cf460?, 0x100010000?})
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/net.go:183 +0x38
net/http.(*connReader).backgroundRead(0x140004aac90)
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:672 +0x48
created by net/http.(*connReader).startBackgroundRead
/opt/homebrew/Cellar/go/1.18.2/libexec/src/net/http/server.go:668 +0xd0
goroutine 72 [select]:
github.com/trezor/trezord-go/core.(*Core).Call.func4()
/Users/matejcik/projekty/prace/trezord-go/core/core.go:586 +0x8c
created by github.com/trezor/trezord-go/core.(*Core).Call
/Users/matejcik/projekty/prace/trezord-go/core/core.go:585 +0x3cc
r0 0x0
r1 0x0
r2 0x0
r3 0x0
r4 0x0
r5 0x140000830d0
r6 0x10363ac56
r7 0x1
r8 0x7e8c83cf21b044d2
r9 0x7e8c83ce4d4b74d2
r10 0xcccccccccccccccd
r11 0xa
r12 0x0
r13 0x34
r14 0x343434206f672e62
r15 0x4c2a282e62737520
r16 0x148
r17 0x21e54f640
r18 0x0
r19 0x6
r20 0x16cfb3000
r21 0x2803
r22 0x16cfb30e0
r23 0x1033290a2
r24 0x21a646000
r25 0x1c20
r26 0x140001c9070
r27 0x860
r28 0x14000002d00
r29 0x16cfb2e00
lr 0x1c46e1ee0
sp 0x16cfb2de0
pc 0x1c46acdb8
fault 0x1c46acdb8
the following script (requires trezorlib and a plugged in Trezor device) will reliably crash Bridge on MacOS M1
script
This is the sequence of events, in plain language:
/readwhile the device is not writing anything/post, sending data which will trigger a response for the pending read/releasethe sessionThis is the full list of calls to Bridge:
It seems that Bridge dislikes disconnecting while actively receiving data from USB.
bridge log
crash backtrace