Repository navigation
frontend: End the process when exit() blocks after shutdown - #4309
Merged
Merged
Conversation
OBS can finish its shutdown and still not quit when a plugin's static destructor blocks in exit() (#3739). The new crate rust/obs-exit-watchdog arms a thread that ends such a process; this commit has todo!() stubs and its Tier 1 tests in obs-tests-gpu (the frontend's Rust category). The cases that arm the watchdog re-run the test binary with an exact selector: a blocked child must end with exit code 124 and one line in its log file and on stderr, also without a log file; a normal exit must not wait and writes nothing. Refs #4065 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A plugin's static destructor or atexit handler can block exit() after main() has returned, and OBS then stays without a window (#3739). After the "Number of memory leaks" line, the frontend arms rust/obs-exit-watchdog with the current log file. Arming opens the log file in append mode, prepares the line and starts one sleeping thread. When the process still runs after 10 s, the thread writes the line to the log file and stderr and ends the process with _exit(124) (TerminateProcess on Windows): not exit(), which runs the same destructors again, and not abort(), which looks like a crash. Only when the frontend's Rust is built (OBS_FRONTEND_RUST). Fixes #4065 Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
enabled auto-merge
November 9, 2026 12:39
|
Claim conflict: keep this PR out of the merge queue until resolved. |
This was referenced Nov 10, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Nov 10, 2026
…t#4584) The quit-hang concept stopped at "Number of memory leaks". Since obs-rust#4309 the exit watchdog adds a last line, and since obs-rust#4560 that line names the library and the plugin that loaded it. Add it as line 7, say how to read the name and where it can mislead, and that gdb must attach within the watchdog's 10 s. Refs obs-rust#4525 Ci-Attestation: {"at":1794333181,"gate":"rust/all/fmt","host":"darwin-arm64","key":"","lane":"lint","parents":["edd24c57e13fc326fd79620d269ee3530dd548fe"],"secs":90,"stamp":"430982cd8ee5f2d77a15469a0b233205","tree":"ccfd658271982e6b830e48f1a9ecbbc301a7088a","v":1,"via":"run"} 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.
Fixes #4065 (the watchdog; naming the blocking plugin is the follow-up proposed in the issue).
Problem
OBS can finish its shutdown and still not quit: a static destructor or
atexithandler of a plugin blocks inexit()aftermain()has returned (#3739). The process then stays without a window and blocks the next start.Change
rust/obs-exit-watchdog, in the frontend's staticlibrust/obs-frontend, C ABI infrontend/utility/obs-exit-watchdog.h.frontend/obs-main.cpp.hpp: after theNumber of memory leaksline,obs_exit_watchdog_arm()with the current log file. Only when the frontend's Rust is built (OBS_FRONTEND_RUST), as the other frontend Rust features._exit(124)(Linux, macOS) orTerminateProcess(Windows). It does not callexit(), which would run the same destructors again, orabort(), which looks like a crash.exit-watchdog: exit did not finish in 10 s: a static destructor or atexit handler is blocking; ending the process. TimeoutTIMEOUT= 10 s, exit codeEXIT_CODE= 124, both named constants.ExitProcessends the other threads before the DLLs' destructors run, so a plugin DLL that blocks there is probably not caught. To test on Windows first, as a follow-up.docs/features.md: a Stability line.Tests
obs-tests-gpu(the frontend's Rust category, no new binary) againsttodo!()stubs: 4 failed (not yet implemented: #4065; the blocked child ended with 101, not 124).a_blocked_process_ends_with_one_line: a child (this test binary, exact selector) arms 200 ms with a log file, then blocks. It must end with 124 within 5 s, with one line on stderr and the line appended to the log file.a_blocked_process_without_its_log_file_still_ends: the same with a log path in a missing directory: 124, one line on stderr.a_normal_exit_is_not_delayed_and_writes_nothing: arms 4 s and returns: exit 0 in under 3 s, no line; a second arm returns false.the_line_names_the_watchdog_and_the_timeout../lintpasses on a Linux host;soldr cargo test -p obs-gpu-status --test obs-tests-gpu --locked --no-run --target x86_64-pc-windows-gnulinks.exit()(static destructors andatexithandlers), so its share of the 1.2 s is smaller; 10 s is more than 8 times the whole quit. Load on the machine changes little in that phase, because OBS's own teardown is already done.obs_module_load) joins a thread that never ends in its destructor (the Quitting the GUI does not end the process on Linux #3739 pattern): exit code 124, 11.05 s after the quit request. Log file:_exitpath as macOS and its Tier 1 cases pass; Windows is the follow-up above.🤖 Generated with Claude Code