Repository navigation
Description
Follow-up to #4065 (closed by #4309, the watchdog itself). This issue is steps 2 and 3 of the order in my #4065 comment: name the module.
Problem
Since #4309, OBS ends the process when exit() does not finish in 10 s, and writes one line:
exit-watchdog: exit did not finish in 10 s: a static destructor or atexit handler is blocking; ending the process
The line does not say which plugin blocks. In #3739 that was the hard part: the cause was a sub-plugin of Advanced Scene Switcher (its MIDI support, with libremidi). We found it only with a debugger on a test machine with the reporter's plugin set. The OBS log cannot show it today:
Loaded Modules:names only the modules that libobs loads. advss loads its sub-plugins with its owndlopen, so the list names only advss.obs_shutdown()freesobs->first_modulebefore the watchdog arms, so the watchdog cannot read the module list.
Location
libobs/obs-module.c.h:obs_open_module(),obs_init_module()(record the libraries that each module brings in).rust/obs-exit-watchdog(find the library where the main thread waits, and write it in the line).frontend/obs-main.cpp.hpp(no change expected; the watchdog arms there).
Class
Diagnostics. No change to the module API or ABI. Existing plugin binaries need no rebuild.
How it is reached
A plugin, or a library that a plugin loads, blocks in a static destructor or an atexit handler. The user quits OBS, and the watchdog fires after 10 s.
Proposed fix and failing test
Two PRs.
PR 1: record which module brought in which libraries.
- Around
os_dlopen(),obs_init_module()andpost_loadof each module, compare the loaded images of the process before and after. The new images belong to that module (for exampleadvanced-scene-switcher: midi.so, libremidi.so). The table stays until exit and does not depend onobs->first_module. - Linux:
dl_iterate_phdr. macOS:_dyld_image_count/_dyld_get_image_name(or_dyld_register_func_for_add_image). - The diff is a pure function (images before, images after, owner), with Tier 1 tests against
todo!()stubs first (RED). - Limits: a library that a plugin thread loads during the load of another module gets the wrong owner. A library loaded later at run time shows as "loaded after startup", with no owner. OBS does not intercept
dlopen.
PR 2: name the library in the watchdog line.
-
When the watchdog fires, take the main thread's stack, map each return address to an image in the table, and write the first image that is not a system library, with its owner:
exit-watchdog: exit did not finish in 10 s: a static destructor or atexit handler is blocking in midi.so (loaded by advanced-scene-switcher); ending the process -
Linux: send a real-time signal to the main thread. The handler only calls
backtrace()into a static buffer; the watchdog thread does the lookup and the write. The handler is installed only when the watchdog fires. -
macOS: no signal.
thread_suspend()andthread_get_state()on the main thread, then a frame-pointer walk. -
RED: extend the frontend: End the process when exit() blocks after shutdown #4309 re-exec test. The child loads a test library with a static destructor that joins a thread that never ends; the watchdog line must name that library and its owner. A manual check with the same plugin in the real app goes in the PR.
Out of scope
- Windows (step 4 of the bug: OBS hangs after shutdown when a plugin's static destructor blocks (exit watchdog) #4065 order).
ExitProcessends the other threads beforeDLL_PROCESS_DETACH, so the watchdog thread may not be alive when DLL destructors run. That needs a test first. - What OBS does with the name at the next start (for example an offer to start without that plugin). That needs a design; it is proposed in discussion Plugin observability: show users which plugin causes a problem #4513.
Open questions
- Should the startup log list the extra libraries of each module? If yes, at info level with system libraries left out, or only at debug level?
- File names only, as
Loaded Modules:does? Full paths can contain the user name.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Nov 10, 2026
/ready
Claiming: #4525 (both PRs of the issue body, one at a time).
Plan:
obs_open_module()/obs_init_module()), Linux and macOS. RED: Tier 1 tests for the before/after diff againsttodo!()stubs.Decisions:
Loaded Modules:does, so the log does not show the user name.First PR (RED) expected 2026-11-11.
vpacher commentedon Nov 10, 2026
Progress on PR 1, with a change of location: the table goes into the frontend's Rust next to the exit watchdog (
rust/obs-exit-watchdog), not into libobs.dl_iterate_phdr) and macOS (dyld): adlopenadds the library and the dependencies it pulls in at the end, and earlier entries keep their place (checked on both). So a module's extra libraries come right after it. Advanced Scene Switcher loads its sub-plugins in itsobs_module_load, so in Quitting the GUI does not end the process on Linux #3739midi.soandlibremidi.sowould followadvanced-scene-switcher.obs_enum_modules). Images before the first module belong to OBS itself, and images new after loading are "loaded in post-load" or "loaded after startup".PR 1: the attribution as a pure function plus the snapshots, with Tier 1 tests in
obs-tests-gpu. No libobs change, and no log output yet (that's PR 2).obs-exit-watchdog: Record which module brought in which libraries (ob…
vpacher commentedon Nov 10, 2026
Claiming: #4525 (continuing the claim above: PR 1 #4549 is merged, PR 2 is #4560).
obs-exit-watchdog: Name the library and the plugin that block exit (o…
vpacher commentedon Nov 10, 2026
Fixed by #4549 (which module brought in which libraries) and #4560 (the watchdog line names the library and its module), on Linux and macOS.
The line now reads, for example:
The owner is one of: the module itself (
an OBS module), the module that loaded the library (loaded by <module>),loaded during the modules' post-load, orloaded after startup. When the stack has only OBS's own frames, or the host cannot capture it, the line stays as it was before.Changes from the plan in the issue:
os_dlopen(). The process's image list is in load order on both hosts, so the owner of a library is the last OBS module before it in that list. libobs needed no change: the frontend notes the modules and the image list after loading and after post-load (PluginManager.cpp.hpp), and the watchdog builds the table when it is armed.name.plugin) and dyld by the binary inside it. A module now also matches a directory of the image's path.Checked by hand in the macOS app with a test plugin that blocks in a static destructor: exit code 124 after 11 s, and the line names the plugin as an OBS module. A normal quit ends in 1 s with exit code 0.
Open question 1 (list each module's extra libraries in the startup log): not done. The table is only built for the watchdog. I suggest we add it only if a report needs it.
Left:
ExitProcessends the other threads beforeDLL_PROCESS_DETACH, so this needs a test first. I'll file it when we start on it.docs/knowledge: Read the exit watchdog's line in a quit hang (obs-rus…