Repository navigation
Description
Follow-up of our #393, which listed this under "Not fixed here": quitting OBS with a "Video Capture Device (PipeWire)" source prints impl_ext_end_proxy called from wrong context, check thread and locking once per camera device, every time, and sometimes aborts with double free or corruption (out) or segfaults on the way out. The scene collection is saved before the crash, but the crash still triggers the AppImage's crash report and gdb relaunch, and the distribution's crash handler.
Location
plugins/linux-pipewire/camera-portal.cpw_portal_connection_free()(line 75), called bycamera_portal_unload()when the module unloads, destroys the device table (line 82). Each entry'scamera_device_free()callspw_proxy_destroy()on the device's node proxy (line 230).- That runs on the thread unloading the module, without the PipeWire thread-loop lock. The PipeWire thread is still running at that point:
obs_pipewire_destroy()stops it only on the next line (line 83), and it is handling the same connection (registry events, node info and params, the replies to the destroys). - PipeWire checks this and prints the warning for every proxy. It reports
Device or resource busywhen the PipeWire thread was running at that very moment, which is the race.
The code is upstream's (camera portal), unchanged in this fork apart from #393's log-line swap. Stock OBS 32.2.2 prints the same warnings on quit.
Class
Crash on quit (data race on the PipeWire connection, SIGABRT / SIGSEGV), plus a warning on every quit.
How it is reached
Quit OBS (window close, File > Exit, SIGTERM) with any PipeWire camera source in the scene collection, after the camera portal has listed the cameras.
Reproduced in the current release
AppImage 33.0.0-beta6-799-gd711a972c, headless: private Xvfb, a private D-Bus session with a fake camera portal, and a private PipeWire daemon (WirePlumber with device monitors off) with 8 producers posing as NV12 cameras. A scene collection with 8 PipeWire camera sources; OBS started, all 8 cameras negotiated, then SIGTERM.
- Plain quits: 110 of 110 print the warning, 10 per quit, and 99 of the 110 include at least one
Device or resource busy(the PipeWire thread was running during the destroy). None of those 110 crashed. - Quits right after reading and setting each camera's format over obs-websocket (the release check's crash case) while a test producer comes and goes: 7 of 80 crashed (5 SIGABRT with
double free or corruption (out)orcorrupted size vs. prev_size while consolidating, 2 SIGSEGV), each right after the warnings, during module unload. The same AppImage with the fix below: 0 of 80, and no warnings.
The release check had hit the same abort once in 15 quits with 4 cameras.
Proposed fix and failing test
Fix: destroy the device table with the PipeWire thread loop locked, through small obs_pipewire_lock()/obs_pipewire_unlock() helpers in pipewire.c.
RED test (cmocka, test_pipewire_camera_unload). It runs the real camera portal against a fake camera portal on a private D-Bus bus and a camera node on a private PipeWire daemon, like test_pipewire_camera_unplug. It is linked with --wrap to follow the camera portal's thread loop and checks every pw_proxy_destroy() made while that loop runs: it must be on the loop thread or under the loop lock. Today 3 of 3 such destroys at unload have no lock, the same in every run, in both libobs lanes.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 13, 2026
Claiming: this issue.
test_pipewire_camera_unloadruns the real camera portal against a fake portal and a private PipeWire daemon, unloads it while its PipeWire thread runs, and checks that every proxy destroyed meanwhile is destroyed on the loop thread or under the loop lock. Today 3 of 3 device proxies are destroyed without the lock.PR today.
test/cmocka: Add a failing test for the camera portal unload
linux-pipewire: Destroy camera devices under the loop lock on unload