Repository navigation
obs-exit-watchdog: Record which module brought in which libraries - #4549
Merged
Merged
Conversation
Which OBS module brought in which libraries (#4525, PR 1): the owner rule on the image list in load order, the table with its post-load and after-startup phases, the address lookup, and the host's own image list. images.rs and the Linux and macOS image lists are todo!() stubs; all 7 new cases in obs-tests-gpu fail with "not yet implemented". Refs #4525 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The owner of an image is the last OBS module before it in the process's image list, which is in load order on Linux and macOS; images before the first module are OBS's own, later ones are marked by the phase they were first seen in (post-load, after startup). The table is sorted by address and finds the entry of an address without allocating. Host lists: dl_iterate_phdr on Linux (the range of the loadable segments, the main program's empty name filled in), dyld on macOS (the __TEXT segment: shared-cache images share __LINKEDIT and interleave their data). Other hosts list nothing yet (#4065 step 4). All 11 exit_watchdog cases of obs-tests-gpu pass on macOS and Linux. Refs #4525 Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
marked this pull request as ready for review
November 10, 2026 12:57
This was referenced Nov 10, 2026
This was referenced Nov 16, 2026
amsterdamboomer
pushed a commit
to amsterdamboomer/obs-studio
that referenced
this pull request
Nov 21, 2026
…-rust#4589) (obs-rust#4890) * test(exit-watchdog): RED for the image list and stack capture on Windows (obs-rust#4589) On Windows the watchdog line names no library: the platform boundary uses the `unsupported` image list and stack capture there, so the host tests take their "not supported" branch. Two Windows tests: - windows_lists_images_and_captures_stacks: the image list is not empty and, on x64, another thread's stack gives frames; - a_library_loaded_later_comes_last: a DLL loaded now is listed after every image loaded before it (the load order the obs-rust#4549 owner rule needs). `malloc` taken by address on Windows is the import stub in the test executable, so the host test looks it up in ucrtbase.dll. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(exit-watchdog): the image list and stack capture on Windows (obs-rust#4589) The watchdog line now names the DLL on Windows when the in-process thread fires (no helper, or a hang in exit() before ExitProcess): - images(): Toolhelp (`CreateToolhelp32Snapshot`, `Module32FirstW`/ `Module32NextW`) lists the modules in the loader's load order, the executable first, so the obs-rust#4549 owner rule works unchanged. A snapshot that fails with ERROR_BAD_LENGTH (a module loads meanwhile) is retried. - capture_stack() on x64: the armed thread is opened at arm time, suspended, its registers read with GetThreadContext, and its stack unwound with RtlLookupFunctionEntry/RtlVirtualUnwind (a frame without unwind data is a leaf: the return address is at the stack pointer). No allocation, no dbghelp. arm64 Windows gets the image list; its stack capture (an arm64 CONTEXT and its unwind) is not built yet and still gives no frames. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
amsterdamboomer
pushed a commit
to amsterdamboomer/obs-studio
that referenced
this pull request
Nov 21, 2026
…aits in (obs-rust#4589) (obs-rust#4891) * test(exit-watchdog): RED for the helper naming the DLL (obs-rust#4589) The helper ends a hang inside ExitProcess, but its line names no library: it has neither the obs-rust#4549 table nor the armed thread. Part 4 hands both over at arm time through a section the helper gets at start. - args_read_every_value / args_without_a_good_table_have_none: the helper reads the section handle from OBS_EXIT_WATCHDOG_TABLE; it is optional, a bad value means none. - the_armed_thread_and_the_table_read_back, a_cut_or_damaged_section_reads_as_nothing: encode_arm/decode_arm (stubs) round-trip the thread id and every owner kind; a cut, empty or damaged section reads as nothing. - windows::the_helpers_line_names_the_dll: a child arms the helper with a table that marks the test executable as loaded by blocker.dll, then blocks in ExitProcess (its TLS callback); the helper's line must name the executable and blocker.dll (x64). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(exit-watchdog): the helper names the DLL a hang in ExitProcess waits in (obs-rust#4589) The helper ended a hang inside ExitProcess (a DLL's detach), but its line named no library: it had neither the obs-rust#4549 table nor the thread. - At start, OBS also hands the helper an unnamed 1 MiB section, in the same explicit handle list (OBS_EXIT_WATCHDOG_TABLE); the process handle it gets adds PROCESS_VM_READ | PROCESS_QUERY_INFORMATION. - arm() writes the table and the calling thread's id into the section (encode_arm: a magic, the thread, then each entry's range, owner and names), then sets the event. Without a section the helper works as before. - On timeout, while OBS still runs, the helper reads the section (decode_arm), opens and suspends that thread, reads its registers and walks its stack with dbghelp's StackWalk64 (loaded at run time, as libobs/obs-win-crash-handler.c.h does), then writes the line naming the first frame's library outside OBS, and ends OBS. x64 only for the walk; arm64 Windows still writes the line without a library. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #4525 (PR 1 of 2: the table; PR 2 names the library in the watchdog line and wires it into the frontend).
What: a table of the process's loaded images with the OBS module that brought each one in, built from the image list in load order. On Linux (
dl_iterate_phdr) and macOS (dyld) adlopenadds the library and its new dependencies at the end of the list, so a module's extra libraries come right after it. The owner of an image is the last OBS module before it; images before the first module are OBS's own; images first seen later are marked "post-load" or "after startup". Advanced Scene Switcher loads its sub-plugins in itsobs_module_load, so in the #3739 casemidi.soandlibremidi.sogetadvanced-scene-switcheras owner. The table is sorted by address and finds an address without allocating, so the watchdog can use it while destructors run (PR 2).Why not in libobs: the reader is the watchdog in the frontend, and a table in libobs would need a new libobs export (see the progress note on #4525).
Host code (
src/platform/only): Linux, the range of the loadable segments, with the main program's empty link-map name filled in. macOS, the__TEXTsegment, because shared-cache images share__LINKEDITand interleave their data. Windows and other hosts list nothing yet (step 4 of the #4065 order).RED c7ef8db: 7 new cases in
obs-tests-gpu(exit_watchdog::images), all failing with "not yet implemented".GREEN 86da2f3: all 11
exit_watchdogcases pass on macOS (arm64) and Linux (x86_64).Tiers: Tier 1 only. No C code changes and no libobs symbol changes, so Tiers 2 to 4 don't apply.
Test cost: new tests: longest under 0.01 s, peak RSS 10.5 MB over 25 runs (Linux), no own threads.
No user-visible change yet (no log output); the features ledger line comes with PR 2.
🤖 Generated with Claude Code