Segmentation fault with libcamera
Version, Distribution, Desktop Environment:
libcamera master, pipewire 0.3.33, NixOS, Plasma
Description of Problem:
There is a segmentation fault in pipewire when using libcamera, which can be reproduced as follows:
How Reproducible:
Happens every time.
Steps to Reproduce:
- Add
libcamera
monitor to pipewire-media-session - Launch
pipewire
-
chmod 777 /dev/media0
for permissions (there's probably a better way to do this) - Launch
pipewire-media-session
- Record from the camera - I used
gstreamer pipewiresrc path=$NODE ! videoconvert ! ximagesink
- Record from the camera again - this time it doesn't matter if you connect to the libcamera or v4l2 node.
The pipewire daemon should have segfaulted by now.
Actual Results:
Segmentation fault, and gstreamer stays in the "PAUSED" state forever.
Expected Results:
No segmentation fault.
Additional Info:
There are also three segmentation faults in the test-spa
test according to coredumpctl list
with no core dump file recorded, I'll look into this later.
pipewire.log pipewire-media-session.log first gstreamer session second gstreamer session
All logs were created with PIPEWIRE_DEBUG=7
Backtrace:
#0 0x00007f5c71ae1b37 in libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const () from /nix/store/0l5sqwyf0an59795nh17r20kv8y19q27-libcamera-unstable-2021-08-14/lib/libcamera.so
#1 0x00007f5c71ba2c56 in LibCamera::stop() () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/spa-0.2/libcamera/libspa-libcamera.so
#2 0x00007f5c71ba069c in impl_node_port_set_param () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/spa-0.2/libcamera/libspa-libcamera.so
#3 0x00007f5c814188f5 in pw_impl_port_set_param () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/libpipewire-0.3.so.0
#4 0x00007f5c813f9eff in do_negotiate () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/libpipewire-0.3.so.0
#5 0x00007f5c813fa779 in check_states () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/libpipewire-0.3.so.0
#6 0x00007f5c8142c2eb in process_work_queue () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/libpipewire-0.3.so.0
#7 0x00007f5c73ad58f6 in source_event_func () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/spa-0.2/support/libspa-support.so
#8 0x00007f5c73ad623b in loop_iterate () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/spa-0.2/support/libspa-support.so
#9 0x00007f5c813fe53b in pw_main_loop_run () from /nix/store/gczyhwf91sm3f6r9w45dgv1b59v764dq-pipewire-0.3.33-lib/lib/libpipewire-0.3.so.0
#10 0x000055a782aa13ea in main ()
Disassembly of relevant function:
(gdb) disassemble
Dump of assembler code for function _ZNK9libcamera20FrameBufferAllocator7buffersEPNS_6StreamE:
0x00007f5c71ae1b20 <+0>: push %rbp
0x00007f5c71ae1b21 <+1>: mov %rdi,%rbp
0x00007f5c71ae1b24 <+4>: push %rbx
0x00007f5c71ae1b25 <+5>: mov %rsi,%rbx
0x00007f5c71ae1b28 <+8>: sub $0x8,%rsp
0x00007f5c71ae1b2c <+12>: movzbl 0xae0dd(%rip),%eax # 0x7f5c71b8fc10 <guard variable for libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1b33 <+19>: test %al,%al
0x00007f5c71ae1b35 <+21>: je 0x7f5c71ae1ba0 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+128>
=> 0x00007f5c71ae1b37 <+23>: mov 0x20(%rbp),%rax
0x00007f5c71ae1b3b <+27>: lea 0x18(%rbp),%rdi
0x00007f5c71ae1b3f <+31>: lea 0xae0da(%rip),%r8 # 0x7f5c71b8fc20 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1b46 <+38>: test %rax,%rax
0x00007f5c71ae1b49 <+41>: je 0x7f5c71ae1b90 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+112>
0x00007f5c71ae1b4b <+43>: mov %rdi,%rsi
0x00007f5c71ae1b4e <+46>: jmp 0x7f5c71ae1b58 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+56>
0x00007f5c71ae1b50 <+48>: mov %rdx,%rax
0x00007f5c71ae1b53 <+51>: test %rax,%rax
0x00007f5c71ae1b56 <+54>: je 0x7f5c71ae1b71 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+81>
0x00007f5c71ae1b58 <+56>: mov 0x10(%rax),%rcx
0x00007f5c71ae1b5c <+60>: mov 0x18(%rax),%rdx
0x00007f5c71ae1b60 <+64>: cmp %rbx,0x20(%rax)
0x00007f5c71ae1b64 <+68>: jb 0x7f5c71ae1b50 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+48>
0x00007f5c71ae1b66 <+70>: mov %rax,%rsi
0x00007f5c71ae1b69 <+73>: mov %rcx,%rax
0x00007f5c71ae1b6c <+76>: test %rax,%rax
0x00007f5c71ae1b6f <+79>: jne 0x7f5c71ae1b58 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+56>
0x00007f5c71ae1b71 <+81>: lea 0xae0a8(%rip),%r8 # 0x7f5c71b8fc20 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1b78 <+88>: cmp %rsi,%rdi
0x00007f5c71ae1b7b <+91>: je 0x7f5c71ae1b90 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+112>
0x00007f5c71ae1b7d <+93>: lea 0x28(%rsi),%r8
0x00007f5c71ae1b81 <+97>: cmp %rbx,0x20(%rsi)
0x00007f5c71ae1b85 <+101>: lea 0xae094(%rip),%rax # 0x7f5c71b8fc20 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1b8c <+108>: cmova %rax,%r8
0x00007f5c71ae1b90 <+112>: add $0x8,%rsp
0x00007f5c71ae1b94 <+116>: mov %r8,%rax
0x00007f5c71ae1b97 <+119>: pop %rbx
0x00007f5c71ae1b98 <+120>: pop %rbp
0x00007f5c71ae1b99 <+121>: ret
0x00007f5c71ae1b9a <+122>: nopw 0x0(%rax,%rax,1)
0x00007f5c71ae1ba0 <+128>: lea 0xae069(%rip),%rdi # 0x7f5c71b8fc10 <guard variable for libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1ba7 <+135>: call 0x7f5c71a7f440 <__cxa_guard_acquire@plt>
0x00007f5c71ae1bac <+140>: test %eax,%eax
0x00007f5c71ae1bae <+142>: je 0x7f5c71ae1b37 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+23>
0x00007f5c71ae1bb0 <+144>: mov 0xac189(%rip),%rdi # 0x7f5c71b8dd40
0x00007f5c71ae1bb7 <+151>: lea 0xac442(%rip),%rdx # 0x7f5c71b8e000
0x00007f5c71ae1bbe <+158>: lea 0xae05b(%rip),%rsi # 0x7f5c71b8fc20 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1bc5 <+165>: movq $0x0,0xae050(%rip) # 0x7f5c71b8fc20 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1bd0 <+176>: movq $0x0,0xae04d(%rip) # 0x7f5c71b8fc28 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty+8>
0x00007f5c71ae1bdb <+187>: movq $0x0,0xae04a(%rip) # 0x7f5c71b8fc30 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty+16>
0x00007f5c71ae1be6 <+198>: call 0x7f5c71a7d140 <__cxa_atexit@plt>
0x00007f5c71ae1beb <+203>: lea 0xae01e(%rip),%rdi # 0x7f5c71b8fc10 <guard variable for libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const::empty>
0x00007f5c71ae1bf2 <+210>: call 0x7f5c71a7c7a0 <__cxa_guard_release@plt>
0x00007f5c71ae1bf7 <+215>: jmp 0x7f5c71ae1b37 <libcamera::FrameBufferAllocator::buffers(libcamera::Stream*) const+23>