zikichombo / sio

sound I/O
BSD 3-Clause "New" or "Revised" License
25 stars 4 forks source link

sio: test failure; unexpected signal during runtime execution #1

Closed mewmew closed 6 years ago

mewmew commented 6 years ago

Test failure at rev a064b49267f5fed3bb217c0ded018a20feb6d5b0

u@x61s ~/g/s/z/sio> go test zikichombo.org/sio/...
sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B]
sio.Dev[0: plughw:0,0 (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt8 SByte SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B SFloat64L SFloat64B]
sio.Dev[0: hw:0,0 (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt32L]
testing sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]
2018/08/07 14:00:56 alsa: underrun
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7fa1a3dbdca2]

runtime stack:
runtime.throw(0x5575a7, 0x2a)
    /usr/lib/go/src/runtime/panic.go:616 +0x81
runtime.sigpanic()
    /usr/lib/go/src/runtime/signal_unix.go:372 +0x28e

goroutine 8 [syscall]:
runtime.cgocall(0x501770, 0xc420110e78, 0x29)
    /usr/lib/go/src/runtime/cgocall.go:128 +0x64 fp=0xc420110e38 sp=0xc420110e00 pc=0x403a74
zikichombo.org/sio._Cfunc_snd_pcm_readi(0x13f9df0, 0x13f76e0, 0x100, 0x0)
    _cgo_gotypes.go:400 +0x4e fp=0xc420110e78 sp=0xc420110e38 pc=0x4f7a0e
zikichombo.org/sio.(*alsaPcm).serveCapture.func1(0x13f9df0, 0x13f76e0, 0x100, 0x0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:197 +0x99 fp=0xc420110eb0 sp=0xc420110e78 pc=0x4fb959
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e2580)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:197 +0x177 fp=0xc420110fd8 sp=0xc420110eb0 pc=0x4f9987
runtime.goexit()
    /usr/lib/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420110fe0 sp=0xc420110fd8 pc=0x459721
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 1 [chan receive]:
testing.(*T).Run(0xc4200c61e0, 0x550ce8, 0xb, 0x559530, 0x46f101)
    /usr/lib/go/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc4200c6000)
    /usr/lib/go/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc4200c6000, 0xc420055df8)
    /usr/lib/go/src/testing/testing.go:777 +0xd0
testing.runTests(0xc4200920e0, 0x7f9ee0, 0x4, 0x4, 0x411389)
    /usr/lib/go/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc4200c2000, 0x0)
    /usr/lib/go/src/testing/testing.go:978 +0x171
main.main()
    _testmain.go:50 +0x151

goroutine 25 [sleep]:
time.Sleep(0x2faf080)
    /usr/lib/go/src/runtime/time.go:102 +0x166
zikichombo.org/sio_test.testInput(0x56a4c0, 0xc4200e2580, 0xc4200c61e0)
    /home/u/goget/src/zikichombo.org/sio/dev_test.go:52 +0x3e
zikichombo.org/sio_test.TestDevices(0xc4200c61e0)
    /home/u/goget/src/zikichombo.org/sio/dev_test.go:29 +0x44e
testing.tRunner(0xc4200c61e0, 0x559530)
    /usr/lib/go/src/testing/testing.go:777 +0xd0
created by testing.(*T).Run
    /usr/lib/go/src/testing/testing.go:824 +0x2e0

goroutine 20 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13c3fc0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13c3fc0, 0xc42002eeb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ca000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ca000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 7 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13efae0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13efae0, 0xc42002feb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200e2420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e2420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 23 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13d2140, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13d2140, 0xc4200306b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ca2c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ca2c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 26 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13d9db0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13d9db0, 0xc4200316b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ca420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ca420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 28 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13cb1f0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13cb1f0, 0xc420031eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ca6e0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ca6e0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 4 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x13e7d90, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x13e7d90, 0xc4201106b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200e2160)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e2160)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e
FAIL    zikichombo.org/sio  2.595s
mewmew commented 6 years ago

Further information follows below. Let me know if there is other info you'd like.

u@x61s ~/g/s/z/sio> go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/u/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/u/goget:/home/u/Desktop/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build855316679=/tmp/go-build -gno-record-gcc-switches"
u@x61s ~/g/s/z/sio> pacman -Q alsa-lib
alsa-lib 1.1.6-1
u@x61s ~/g/s/z/sio> uname -a
Linux x61s 4.17.11-arch1 #1 SMP PREEMPT Sun Jul 29 10:11:16 UTC 2018 x86_64 GNU/Linux
u@x61s ~/g/s/z/sio> go test -v zikichombo.org/sio/...
sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B]
sio.Dev[0: plughw:0,0 (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt8 SByte SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B SFloat64L SFloat64B]
sio.Dev[0: hw:0,0 (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt32L]
=== RUN   TestAlsaOpen
--- PASS: TestAlsaOpen (2.05s)
=== RUN   TestDevices
testing sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]
2018/08/07 14:03:43 alsa: underrun
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x610000cdfd90 pc=0x7f515a8ee0c7]

runtime stack:
runtime.throw(0x5575a7, 0x2a)
    /usr/lib/go/src/runtime/panic.go:616 +0x81
runtime.sigpanic()
    /usr/lib/go/src/runtime/signal_unix.go:372 +0x28e

goroutine 25 [syscall]:
runtime.cgocall(0x501470, 0xc420053c60, 0x29)
    /usr/lib/go/src/runtime/cgocall.go:128 +0x64 fp=0xc420053c20 sp=0xc420053be8 pc=0x403a74
zikichombo.org/sio._Cfunc_snd_pcm_open(0xc4200e65a8, 0xcd45e0, 0x0, 0x0)
    _cgo_gotypes.go:371 +0x4d fp=0xc420053c60 sp=0xc420053c20 pc=0x4f785d
zikichombo.org/sio.(*alsaPcm).open.func1(0xc4200e65a8, 0xcd45e0, 0x0, 0xc420053d50)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:73 +0xbc fp=0xc420053c98 sp=0xc420053c60 pc=0x4faf4c
zikichombo.org/sio.(*alsaPcm).open(0xc4200e6580, 0x0, 0x0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:73 +0x8b fp=0xc420053da0 sp=0xc420053c98 pc=0x4f877b
zikichombo.org/sio.(*Dev).Output(0x7f9e20, 0x56a100, 0xc42008c420, 0x4, 0x100, 0x56a4c0, 0xc4200ceb00, 0x0, 0x0)
    /home/u/goget/src/zikichombo.org/sio/dev_alsa.go:44 +0x177 fp=0xc420053de0 sp=0xc420053da0 pc=0x4f8087
zikichombo.org/sio_test.TestDevices(0xc4200ca1e0)
    /home/u/goget/src/zikichombo.org/sio/dev_test.go:32 +0x29e fp=0xc420053fa8 sp=0xc420053de0 pc=0x4ffe2e
testing.tRunner(0xc4200ca1e0, 0x559530)
    /usr/lib/go/src/testing/testing.go:777 +0xd0 fp=0xc420053fd0 sp=0xc420053fa8 pc=0x4b88d0
runtime.goexit()
    /usr/lib/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420053fd8 sp=0xc420053fd0 pc=0x459721
created by testing.(*T).Run
    /usr/lib/go/src/testing/testing.go:824 +0x2e0

goroutine 1 [chan receive]:
testing.(*T).Run(0xc4200ca1e0, 0x550ce8, 0xb, 0x559530, 0x46f101)
    /usr/lib/go/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc4200ca000)
    /usr/lib/go/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc4200ca000, 0xc420057df8)
    /usr/lib/go/src/testing/testing.go:777 +0xd0
testing.runTests(0xc42009a0c0, 0x7f9ee0, 0x4, 0x4, 0x411389)
    /usr/lib/go/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc4200c6000, 0x0)
    /usr/lib/go/src/testing/testing.go:978 +0x171
main.main()
    _testmain.go:50 +0x151

goroutine 20 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcadfc0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcadfc0, 0xc420030eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ce000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ce000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 23 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcbc140, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcbc140, 0xc4200326b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ce2c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ce2c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 4 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcb53b0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcb53b0, 0xc420032eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200e6160)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e6160)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 26 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcc3db0, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcc3db0, 0xc4200336b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ce420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ce420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 6 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcd1d40, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcd1d40, 0xc420033eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200e62c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e62c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 7 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xcd9b50, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xcd9b50, 0xc42010c6b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200e6420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200e6420)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 31 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0xce3e90, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0xce3e90, 0xc42010ceb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200ceb00)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200ceb00)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e
FAIL    zikichombo.org/sio  2.674s
wsc1 commented 6 years ago

Thanks!

I think I have isolated the problem sufficiently that you can make use of sio using the temporary workaround below.

The device scanning code, which is still very rough, seems to be the culprit, and it is not yet actually needed for capture/playback with ALSA. The temp workaround simply bypasses it.

Does it work for you with the workaround?

Scott

diff --git a/dev_alsa.go b/dev_alsa.go index 248fd68..d5fbfd0 100644 --- a/dev_alsa.go +++ b/devalsa.go @@ -55,6 +55,9 @@ func init() { } j := 0 for , d := range devs {

mewmew commented 6 years ago

Does it work for you with the workaround?

I'll try. To fix the markdown representation of the diff, please insert raw quotes. ``` around the block.

mewmew commented 6 years ago

The workaround worked. I heard sounds playing. Yay! And, the test case that did fail was related to locating devices, which is to be expected given the nature of the workaround.

u@x61s ~/g/s/z/sio> go test -v
=== RUN   TestAlsaOpen
--- PASS: TestAlsaOpen (2.45s)
=== RUN   TestDevices
--- FAIL: TestDevices (0.00s)
    dev_test.go:43: no inputs found on system.
    dev_test.go:46: no outputs found on system.
=== RUN   TestAlsaIn
2018/08/09 01:22:52 alsa: underrun
--- PASS: TestAlsaIn (4.01s)
=== RUN   TestAlsaOut
started q at 2018-08-09 01:22:56.976595565 +0900 JST m=+6.488262809
starting delayed at 2018-08-09 01:22:57.965943262 +0900 JST m=+7.477610506.
sent 88064 in 2.986670181s
--- PASS: TestAlsaOut (4.00s)
FAIL
exit status 1
FAIL    zikichombo.org/sio  10.500s
mewmew commented 6 years ago

I tried a bit more, and it seems the crash is related to the input device.

If I use the code at rev 960bd048be9ac0499a525d14c3c064acbfefdb34, and only add the following change to dev_test.go, then the test cases work.

u@x61s ~/g/s/z/sio> git diff
diff --git a/dev_test.go b/dev_test.go
index 0d3b9f1..93c6bbc 100644
--- a/dev_test.go
+++ b/dev_test.go
@@ -22,13 +22,15 @@ func TestDevices(t *testing.T) {
                fmt.Printf("testing %v\n", d)
                for _, sc := range d.SampleCodecs {
                        for _, v := range []sound.Form{sound.MonoCd(), sound.StereoCd()} {
-                               i, ie := d.Input(v, sc, 256)
-                               if ie != nil {
-                                       t.Errorf("device %s can't make input for %s, %s: %s\n", d, v, sc, ie)
-                               } else {
-                                       testInput(i, t)
-                                       nIns++
-                               }
+                               /*
+                                       i, ie := d.Input(v, sc, 256)
+                                       if ie != nil {
+                                               t.Errorf("device %s can't make input for %s, %s: %s\n", d, v, sc, ie)
+                                       } else {
+                                               testInput(i, t)
+                                               nIns++
+                                       }
+                               */
                                o, oe := d.Output(v, sc, 256)
                                if oe != nil {
                                        t.Errorf("device %s can't make output for %s, %s: %s\n", d, v, sc, oe)

The test cases work, except for the "no inputs found", which is to be expected given that it was disabled in the test case.

u@x61s ~/g/s/z/sio> go test
sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B]
testing sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]
--- FAIL: TestDevices (0.86s)
    dev_test.go:45: no inputs found on system.
started q at 2018-08-10 16:54:31.385547085 +0900 JST m=+6.906108026
2018/08/10 16:54:31 alsa: underrun
starting delayed at 2018-08-10 16:54:32.385683026 +0900 JST m=+7.906243827.
sent 88064 in 2.995121746s
FAIL
exit status 1
FAIL    zikichombo.org/sio  10.908s

Do you have any suggestions for how to further troubleshoot?

Without the above diff, I get the following panic as before:

u@x61s ~/g/s/z/sio> go test -v
sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]: [SInt16L SInt16B SInt24L SInt24B SInt32L SInt32B SFloat32L SFloat32B]
=== RUN   TestAlsaOpen
--- PASS: TestAlsaOpen (2.05s)
=== RUN   TestDevices
testing sio.Dev[0: default (0,0)@[0nHz..0nHz] i=false o=false s=false]
2018/08/10 16:57:39 alsa: underrun
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7f47f99b6ca2]

runtime stack:
runtime.throw(0x556aaf, 0x2a)
    /usr/lib/go/src/runtime/panic.go:616 +0x81
runtime.sigpanic()
    /usr/lib/go/src/runtime/signal_unix.go:372 +0x28e

goroutine 27 [syscall]:
runtime.cgocall(0x501100, 0xc42012a678, 0x29)
    /usr/lib/go/src/runtime/cgocall.go:128 +0x64 fp=0xc42012a638 sp=0xc42012a600 pc=0x403a74
zikichombo.org/sio._Cfunc_snd_pcm_readi(0x7f47c8029960, 0x7f47c8029dd0, 0x100, 0x0)
    _cgo_gotypes.go:400 +0x4e fp=0xc42012a678 sp=0xc42012a638 pc=0x4f789e
zikichombo.org/sio.(*alsaPcm).serveCapture.func1(0x7f47c8029960, 0x7f47c8029dd0, 0x100, 0x20002)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:197 +0x99 fp=0xc42012a6b0 sp=0xc42012a678 pc=0x4fb7e9
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200c8840)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:197 +0x177 fp=0xc42012a7d8 sp=0xc42012a6b0 pc=0x4f9817
runtime.goexit()
    /usr/lib/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc42012a7e0 sp=0xc42012a7d8 pc=0x459721
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 1 [chan receive]:
testing.(*T).Run(0xc4200c21e0, 0x550228, 0xb, 0x558a10, 0x46f101)
    /usr/lib/go/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc4200c2000)
    /usr/lib/go/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc4200c2000, 0xc420055df8)
    /usr/lib/go/src/testing/testing.go:777 +0xd0
testing.runTests(0xc4200a4060, 0x7f8ec0, 0x4, 0x4, 0x411389)
    /usr/lib/go/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc4200bc000, 0x0)
    /usr/lib/go/src/testing/testing.go:978 +0x171
main.main()
    _testmain.go:50 +0x151

goroutine 22 [sleep]:
time.Sleep(0x2faf080)
    /usr/lib/go/src/runtime/time.go:102 +0x166
zikichombo.org/sio_test.testInput(0x5698e0, 0xc4200c8840, 0xc4200c21e0)
    /home/u/goget/src/zikichombo.org/sio/dev_test.go:52 +0x3e
zikichombo.org/sio_test.TestDevices(0xc4200c21e0)
    /home/u/goget/src/zikichombo.org/sio/dev_test.go:29 +0x44e
testing.tRunner(0xc4200c21e0, 0x558a10)
    /usr/lib/go/src/testing/testing.go:777 +0xd0
created by testing.(*T).Run
    /usr/lib/go/src/testing/testing.go:824 +0x2e0

goroutine 19 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x22a3800, 0x0)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x22a3800, 0xc42002e6b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200c8000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200c8000)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 23 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x7f47c800fb90, 0x7f4700000000)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x7f47c800fb90, 0xc420033eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200c82c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200c82c0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 26 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x7f47c8019970, 0x7f4700000000)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x7f47c8019970, 0xc4200346b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200c86e0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200c86e0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 25 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x7f47c8011730, 0x7f4700000000)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x7f47c8011730, 0xc42002f6b0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200c8580)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200c8580)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e

goroutine 10 [syscall]:
zikichombo.org/sio._Cfunc_snd_pcm_drain(0x7f47c80218a0, 0x7f4700000000)
    _cgo_gotypes.go:139 +0x49
zikichombo.org/sio.(*alsaPcm).pcmClose.func2(0x7f47c80218a0, 0xc420035eb0)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x56
zikichombo.org/sio.(*alsaPcm).pcmClose(0xc4200da580)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:366 +0x38
zikichombo.org/sio.(*alsaPcm).serveCapture(0xc4200da580)
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:221 +0x3e1
created by zikichombo.org/sio.(*alsaPcm).open
    /home/u/goget/src/zikichombo.org/sio/pcm_alsa.go:113 +0x59e
exit status 2
FAIL    zikichombo.org/sio  2.652s
wsc1 commented 6 years ago

On 10 August 2018 at 09:51, Robin Eklind notifications@github.com wrote:

I tried a bit more, and it seems the crash is related to the input device.

If I use the code at rev 960bd04 https://github.com/zikichombo/sio/commit/960bd048be9ac0499a525d14c3c064acbfefdb34, and only add the following change to dev_test.go, then the test cases work.

u@x61s ~/g/s/z/sio> git diffdiff --git a/dev_test.go b/dev_test.go index 0d3b9f1..93c6bbc 100644--- a/dev_test.go+++ b/devtest.go@@ -22,13 +22,15 @@ func TestDevices(t *testing.T) { fmt.Printf("testing %v\n", d) for , sc := range d.SampleCodecs { for _, v := range []sound.Form{sound.MonoCd(), sound.StereoCd()} {- i, ie := d.Input(v, sc, 256)- if ie != nil {- t.Errorf("device %s can't make input for %s, %s: %s\n", d, v, sc, ie)- } else {- testInput(i, t)- nIns++- }+ /+ i, ie := d.Input(v, sc, 256)+ if ie != nil {+ t.Errorf("device %s can't make input for %s, %s: %s\n", d, v, sc, ie)+ } else {+ testInput(i, t)+ nIns+++ }+ / o, oe := d.Output(v, sc, 256) if oe != nil { t.Errorf("device %s can't make output for %s, %s: %s\n", d, v, sc, oe)

The test cases work, except for the "no inputs found", which is to be expected given that it was disabled in the test case.

Great!

Do you have any suggestions for how to further troubleshoot?

If you fiddle with the timeout (make it longer) in the test and it works, then one thing might be the ALSA sio.Input.Close() would need bidirectional communication with serveCapture() to wait for it to close. Or perhaps comment out pcm_alsa.go:365. The drain call isn't strictly necessary.

Thanks for playing with it! I can only do it conveniently via virtual box with darwin host and there are known bugs with the vb driver there. So when I play with, there is always a significant risk that what I see isn't what others would on the corresponding hardware.

wsc1 commented 6 years ago

Another idea is to try alsa compiled with thread support. I'm not sure how to do that with apt, though.

wsc1 commented 6 years ago

To reduce overall work to getting this working right, this issue is awaiting progress on structuring the host interface.

The workaround here will unfortunately need to suffice for the coming weeks.

wsc1 commented 6 years ago

As the host re-structuring is up for review, and the ALSA device scanning consequently scheduled to be redone, this bug should no longer be relevant, closing