google / google/gousb

Segfault during endpoint write

Open
#137 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
932
Forks
136
PR merge metrics
No merged PRs in 30d

Description

I encountered a segfault during a USB endpoint write.

Unfortunately, I don't have much context beyond the following. In general, my expectation is that `gousb` should prevent any segfaults by proper management of the underlying connection, but maybe I have a misunderstanding of proper usage of the go package. From a review of the client code for `gousb`, there is no concurrent access that could potentially cause this.

```
SIGSEGV: segmentation violation
PC=0x7f6703537c49 m=4 sigcode=128 addr=0x0
signal arrived during cgo execution

goroutine 544 gp=0xc000682e00 m=4 mp=0xc0003ed808 [syscall]:
runtime.cgocall(0xa57cd0, 0xc0023d1548)
/usr/local/go/src/runtime/cgocall.go:167 +0x4b fp=0xc0023d1520 sp=0xc0023d14e8 pc=0x47c30b
github.com/google/gousb._Cfunc_submit(0x7f66b0004f00)
_cgo_gotypes.go:680 +0x45 fp=0xc0023d1548 sp=0xc0023d1520 pc=0x8cbb25
github.com/google/gousb.libusbImpl.submit.func1(...)
/workspaces/my_project/vendor/github.com/google/gousb/libusb.go:470
github.com/google/gousb.libusbImpl.submit({}, 0x7f66b0004f00)
/workspaces/my_project/vendor/github.com/google/gousb/libusb.go:470 +0x35 fp=0xc0023d1578 sp=0xc0023d1548 pc=0x8ce515
github.com/google/gousb.(*libusbImpl).submit(0xc0041f53b0?, 0x120e500?)
:1 +0x25 fp=0xc0023d1590 sp=0xc0023d1578 pc=0x8d1a65
github.com/google/gousb.(*usbTransfer).submit(0xc0041d6740)
/workspaces/my_project/vendor/github.com/google/gousb/transfer.go:51 +0x90 fp=0xc0023d15e0 sp=0xc0023d1590 pc=0x8c7b90
github.com/google/gousb.(*endpoint).transfer(0xc000822070, {0xcddd20, 0xc0041f53b0}, {0xc0041f6c00, 0x3f7, 0x1?})
/workspaces/my_project/vendor/github.com/google/gousb/endpoint.go:98 +0xf5 fp=0xc0023d1668 sp=0xc0023d15e0 pc=0x8c6515
github.com/google/gousb.(*OutEndpoint).WriteContext(...)
/workspaces/my_project/vendor/github.com/google/gousb/endpoint.go:170
```

Any expertise to help explain what would surface this would be helpful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.