Assertion 'uchunk->index % bq->base == 0' failed at ../src/pulsecore/memblockq.c:289, function pa_memblockq_push()
Summary
Recording on a sound card with 32 inputs causes the assertion failure mentioned in the title. uchunk->index
is 64, while bq->base
is 128.
Unfortunately, the setup is a bit complicated (using Python code—this happens when starting the friture audio visualization program if the card with 32 inputs is inserted, or otherwise when that card is inserted. I tried to understand what it does; it seems fairly vanilla, but I don't know the pulseaudio API well. It uses Python's rtmixer library, which uses sounddevice.
NOTE: I don't really know that this is due to the large number of inputs, but I suspect so. I tried to read the memblock logic, but it's sufficiently convoluted for me to not grasp how it's intended to work quickly.
This is the device it's run on (from Python's sounddevice library). FWIW, I don't 100% understand why so many input channels; I think the device supports 8 simultaneous channels, and I don't fully understand where this "default" comes from.
In [1]: import sounddevice
In [2]: devices = sounddevice.query_devices(kind='output')
In [3]: devices
Out[3]:
{'name': 'default',
'index': 16,
'hostapi': 0,
'max_input_channels': 32,
'max_output_channels': 32,
'default_low_input_latency': 0.008684807256235827,
'default_low_output_latency': 0.008684807256235827,
'default_high_input_latency': 0.034807256235827665,
'default_high_output_latency': 0.034807256235827665,
'default_samplerate': 44100.0}
When running with pulseaudio debug logging (see below), I see that some suspicious (to me) "prebuf=64, minreq=64" is involved.
environment
Steps to reproduce
- Attach a RME Fireface UCX II USB sound card in class compliant mode. (I know. Sorry.)
- Either run the appimage of friture or build it from source.
What is the current bug behavior?
The program crashes at start with the mentioned assertion failure.
(friture) sami@sli:~/build/friture$ PULSE_LOG=10 ./main.py
2023-01-19 20:10:47,289 INFO friture.analyzer: Friture 0.49 starting on Linux (linux)
2023-01-19 20:10:47,289 INFO friture.analyzer: QML path: PyQt5.QtCore.QUrl('file:///home/sami/build/friture/friture/')
2023-01-19 20:10:47,413 INFO friture.audiobackend: Initializing audio backend
2023-01-19 20:10:47,413 INFO friture.audiobackend: Found 14 input devices and 16 output devices
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=64, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=64, prebuf=64, minreq=64 maxrewind=0
2023-01-19 20:10:47,485 INFO friture.audiobackend: Supported formats for 'default' on 'ALSA': ['22050 Hz, float32', '22050 Hz, int16', '22050 Hz, int8', '44100 Hz, float32', '44100 Hz, int16', '44100 Hz, int8', '48000 Hz, float32', '48000 Hz, int16', '48000 Hz, int8', '96000 Hz, float32', '96000 Hz, int16', '96000 Hz, int8']
2023-01-19 20:10:47,485 INFO friture.audiobackend: Opening the stream for device 'default'
Parsing configuration file '/etc/pulse/client.conf'
Failed to open configuration file '/etc/pulse/client.conf.d/01-enable-autospawn.conf': No such file or directory
Using shared memfd memory pool with 1024 slots of size 64.0 KiB each, total size is 64.0 MiB, maximum usable slot size is 65472
Trying to connect to /run/user/1000/pulse/native...
SHM possible: yes
Protocol version: remote 35, local 35
Negotiated SHM: yes
Memfd possible: yes
Negotiated SHM type: shared memfd
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
2023-01-19 20:10:47,497 INFO friture.audiobackend: Device claims 42 ms latency
memblockq requested: maxlength=4194304, tlength=0, base=128, prebuf=1, minreq=0 maxrewind=0
memblockq sanitized: maxlength=4194304, tlength=4194304, base=128, prebuf=128, minreq=128 maxrewind=0
2023-01-19 20:10:47,509 INFO friture.audiobackend: Success
Assertion 'uchunk->index % bq->base == 0' failed at ../src/pulsecore/memblockq.c:289, function pa_memblockq_push(). Aborting.
Aborted (core dumped)
Here's backtrace from GDB, pulseaudio built without optimization (-full below):
Assertion 'uchunk->index % bq->base == 0' failed at ../src/pulsecore/memblockq.c:289, function pa_memblockq_push(). Aborting.
[New Thread 0x7fff7e7fd640 (LWP 302614)]
Thread 40 "threaded-ml" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb0bf9640 (LWP 302612)]
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140736158733888) at ./nptl/pthread_kill.c:44
Download failed: Invalid argument. Continuing without source file ./nptl/./nptl/pthread_kill.c.
44 ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140736158733888) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140736158733888) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140736158733888, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff7c78476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7c5e7f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff04ff908 in pa_memblockq_push (bq=0x7fff88007c00, uchunk=0x7fffb0bf88e0) at ../src/pulsecore/memblockq.c:289
#6 0x00007ffff0501779 in pa_memblockq_push_align (bq=0x7fff88007c00, chunk=0x7fffb0bf8990) at ../src/pulsecore/memblockq.c:783
#7 0x00007ffff055f003 in pstream_memblock_callback (p=0x7fff88003140, channel=1, offset=0, seek=PA_SEEK_RELATIVE, chunk=0x7fffb0bf8990, userdata=0x5555568c0710)
at ../src/pulse/context.c:433
#8 0x00007ffff050c327 in memblock_complete (p=0x7fff88003140, re=0x7fff88003308) at ../src/pulsecore/pstream.c:852
#9 0x00007ffff050ccb9 in do_read (p=0x7fff88003140, re=0x7fff88003308) at ../src/pulsecore/pstream.c:1014
#10 0x00007ffff05097a2 in do_pstream_read_write (p=0x7fff88003140) at ../src/pulsecore/pstream.c:254
#11 0x00007ffff0509a4d in srb_callback (srb=0x7fff880036e0, userdata=0x7fff88003140) at ../src/pulsecore/pstream.c:296
#12 0x00007ffff050f29c in srbchannel_rwloop (sr=0x7fff880036e0) at ../src/pulsecore/srbchannel.c:190
#13 0x00007ffff050f2fe in semread_cb (m=0x5555568cb778, e=0x7fff88003790, fd=29, events=PA_IO_EVENT_INPUT, userdata=0x7fff880036e0) at ../src/pulsecore/srbchannel.c:210
#14 0x00007ffff057d30c in dispatch_pollfds (m=0x5555568cb720) at ../src/pulse/mainloop.c:676
#15 0x00007ffff057e176 in pa_mainloop_dispatch (m=0x5555568cb720) at ../src/pulse/mainloop.c:917
#16 0x00007ffff057e307 in pa_mainloop_iterate (m=0x5555568cb720, block=1, retval=0x0) at ../src/pulse/mainloop.c:948
#17 0x00007ffff057e36a in pa_mainloop_run (m=0x5555568cb720, retval=0x0) at ../src/pulse/mainloop.c:963
#18 0x00007ffff0593058 in thread (userdata=0x5555568f3f50) at ../src/pulse/thread-mainloop.c:101
#19 0x00007ffff05283d8 in internal_thread_func (userdata=0x555556b070f0) at ../src/pulsecore/thread-posix.c:81
#20 0x00007ffff7ccab43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#21 0x00007ffff7d5ca00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) bt -full
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140736158733888) at ./nptl/pthread_kill.c:44
tid = <optimized out>
ret = 0
pd = 0x7fffb0bf9640
old_mask = {__val = {140736158729936, 93825012643704, 8835580745, 72198330196657872, 8835580745, 140737351297668, 140735475121456, 1, 140736158729943, 1, 140736158729984, 140737225012109, 93825012643832, 1, 140736158729943, 114634491584}}
ret = <optimized out>
#1 __pthread_kill_internal (signo=6, threadid=140736158733888) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140736158733888, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff7c78476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
ret = <optimized out>
#4 0x00007ffff7c5e7f3 in __GI_abort () at ./stdlib/abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x7fffb0bf8790, sa_sigaction = 0x7fffb0bf8790}, sa_mask = {__val = {140737225390226, 2416050240, 140735609438208, 140736158730192, 140737225133324, 128, 5747123744, 140735609438248, 140735475115132, 128, 140736158730240, 140737225551113, 8326514572, 140735609438208, 140736158730240, 140737225128694}}, sa_flags = -1878982656, sa_restorer = 0x7fffb0bf88b0}
sigs = {__val = {32, 4288, 140736158730240, 140737225122145, 140737225394376, 140737225359104, 140737225390096, 289, 206158430248, 140736158730256, 140736158730064, 1769699373704571392, 93825012737744, 140736158730096, 140737225128694, 93825012737744}}
#5 0x00007ffff04ff908 in pa_memblockq_push (bq=0x7fff88007c00, uchunk=0x7fffb0bf88e0) at ../src/pulsecore/memblockq.c:289
q = 0x7fff90010000
n = 0x7fffb0bf8860
chunk = {memblock = 0x7fffb0bf88b0, index = 140737225127580, length = 140736158730464}
old = 140735609372672
__PRETTY_FUNCTION__ = "pa_memblockq_push"
__func__ = "pa_memblockq_push"
#6 0x00007ffff0501779 in pa_memblockq_push_align (bq=0x7fff88007c00, chunk=0x7fffb0bf8990) at ../src/pulsecore/memblockq.c:783
r = 0
rchunk = {memblock = 0x7fff90010000, index = 64, length = 4224}
__PRETTY_FUNCTION__ = "pa_memblockq_push_align"
__func__ = "pa_memblockq_push_align"
#7 0x00007ffff055f003 in pstream_memblock_callback (p=0x7fff88003140, channel=1, offset=0, seek=PA_SEEK_RELATIVE, chunk=0x7fffb0bf8990, userdata=0x5555568c0710) at ../src/pulse/context.c:433
c = 0x5555568c0710
s = 0x7fff78000ba0
__PRETTY_FUNCTION__ = "pstream_memblock_callback"
__func__ = "pstream_memblock_callback"
#8 0x00007ffff050c327 in memblock_complete (p=0x7fff88003140, re=0x7fff88003308) at ../src/pulsecore/pstream.c:852
chunk = {memblock = 0x7fff90010000, index = 0, length = 4288}
offset = 0
#9 0x00007ffff050ccb9 in do_read (p=0x7fff88003140, re=0x7fff88003308) at ../src/pulsecore/pstream.c:1014
d = 0x7fff90010040
l = 4288
r = 4288
release_memblock = 0x7fff90010000
__PRETTY_FUNCTION__ = "do_read"
__func__ = "do_read"
#10 0x00007ffff05097a2 in do_pstream_read_write (p=0x7fff88003140) at ../src/pulsecore/pstream.c:254
r = 0
__PRETTY_FUNCTION__ = "do_pstream_read_write"
__func__ = "do_pstream_read_write"
#11 0x00007ffff0509a4d in srb_callback (srb=0x7fff880036e0, userdata=0x7fff88003140) at ../src/pulsecore/pstream.c:296
b = false
p = 0x7fff88003140
__PRETTY_FUNCTION__ = "srb_callback"
__func__ = "srb_callback"
#12 0x00007ffff050f29c in srbchannel_rwloop (sr=0x7fff880036e0) at ../src/pulsecore/srbchannel.c:190
#13 0x00007ffff050f2fe in semread_cb (m=0x5555568cb778, e=0x7fff88003790, fd=29, events=PA_IO_EVENT_INPUT, userdata=0x7fff880036e0) at ../src/pulsecore/srbchannel.c:210
sr = 0x7fff880036e0
#14 0x00007ffff057d30c in dispatch_pollfds (m=0x5555568cb720) at ../src/pulse/mainloop.c:676
e = 0x7fff88003790
r = 0
k = 1
__PRETTY_FUNCTION__ = "dispatch_pollfds"
__func__ = "dispatch_pollfds"
#15 0x00007ffff057e176 in pa_mainloop_dispatch (m=0x5555568cb720) at ../src/pulse/mainloop.c:917
dispatched = 0
__PRETTY_FUNCTION__ = "pa_mainloop_dispatch"
__func__ = "pa_mainloop_dispatch"
#16 0x00007ffff057e307 in pa_mainloop_iterate (m=0x5555568cb720, block=1, retval=0x0) at ../src/pulse/mainloop.c:948
r = 1
__PRETTY_FUNCTION__ = "pa_mainloop_iterate"
__func__ = "pa_mainloop_iterate"
#17 0x00007ffff057e36a in pa_mainloop_run (m=0x5555568cb720, retval=0x0) at ../src/pulse/mainloop.c:963
r = 1
#18 0x00007ffff0593058 in thread (userdata=0x5555568f3f50) at ../src/pulse/thread-mainloop.c:101
m = 0x5555568f3f50
mask = {__val = {18446744067267100671, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140737350831531, 0, 0, 0, 0}}
prev_mask = {__val = {0 <repeats 16 times>}}
sa = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 140736158733888, 2965345856, 140736158731296, 140737225679623, 0, 0, 4294967296, 93825012908736, 140736158731344, 18446744068084962880, 140736158731344, 140737225323755, 0, 93825006316096, 0}}, sa_flags = 0, sa_restorer = 0x0}
#19 0x00007ffff05283d8 in internal_thread_func (userdata=0x555556b070f0) at ../src/pulsecore/thread-posix.c:81
t = 0x555556b070f0
__PRETTY_FUNCTION__ = "internal_thread_func"
__func__ = "internal_thread_func"
#20 0x00007ffff7ccab43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
ret = <optimized out>
pd = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737488329248, 5868006575051838287, 140736158733888, 2, 140737350772816, 140737488329600, -5868126968907623601, -5867988577583033521}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
#21 0x00007ffff7d5ca00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
What is the expected correct behavior?
There should be no assertion failure.