Repository navigation
libobs: send an output's stop signal once when it is stopped again during its destroy (#3799) - #4843
Merged
Merged
Conversation
…p once (#3799) Older source-record versions force-stop their recording output, release it from their stop handler and free the handler's data there, without disconnecting it. When the release finds the output still active, the destroy stops it again; for an output that never got a packet the end added for #3764 then sends a second stop, the handler runs on freed data and glibc aborts (the reporter's backtrace). The new case connects a stop handler that stays connected, force-stops an output that never got a packet, releases it as soon as the first stop arrived, and expects one stop signal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ring its destroy (#3799) The end of capture added for #3764 ran on every stop of an encoded output that never got a packet, also on the second stop that obs_output_destroy() makes when the output still counts as active while its end thread runs. That call found the capture already ended and sent the stop signal again. Older source-record versions free their stop handler's data on the first stop signal and never disconnect it, so the second one ran the handler on freed data: a double free, and OBS aborted right after a recording started (the reporter's backtrace in #3799). The end now runs only while the capture is still active; the first stop still ends a capture that never got a packet (#3764). Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
marked this pull request as ready for review
November 13, 2026 12:43
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 #3799 (the crash in the reporter's backtrace; other crashes in that issue have no trace yet).
Problem
The reporter's backtrace (19:30 crash, SIGABRT):
obs_output_release→ (libobs: destroy, stop) →signal_handler_signal→release_output_stopped(source-record.so) → glibcabort()Older source-record versions (before 0.5.0) force-stop their recording output. Their
stophandler queues the output's release and frees the handler's data, but never disconnects the handler. So they are safe only ifstopcomes once.The end of capture added for #3764 (
5f71441ee, the hang at exit, #3739) runs inobs_output_actual_stop()for an encoded output that never got a packet. It also ran on the second stop thatobs_output_destroy()makes when the output still counts as active, because its end thread is still running. That call found the capture already ended and took the "not active" branch ofobs_output_end_data_capture, which sendsstopagain. The handler then ran on freed data, and glibc aborted. The reporter's 0-byte recordings are that case: the crash came within about 2 s of starting the recording, before the first packet. Upstream OBS sendsstoponce there.Change
libobs/obs-output.c.h: the end of capture for an output without a packet now runs only while the capture is still active (data_active). The first stop still ends such a capture (#3764). A second stop of the same output (from the destroy) sends no secondstop.docs/features.md: one entry.Tests
RED
ef50349d7:force_stop_and_release_signal_stop_onceintest_output_stop_without_packets. It does what source-record does: astophandler that stays connected, a force stop of an encoded output that never got a packet, and a release as soon as the firststoparrived. It expects onestopsignal. Before the fix it fails. CI run of the RED commit (run 43412660365), Rust Tier 2 Linux, tests OFF and ON:force stop and release: 2 stop signal(s), output still active at the release, the only failure (1 of 930).GREEN
4d4d88afc. The two #3764 cases of the same test (the stop finishes and the release returns, with and without packets) keep passing.Tiers: Tier 2 (this cmocka test against libobs). No Tier 1 or 3: no Rust code or ported unit changes. No Tier 4: no protocol change.
Test cost: the new case runs in a child process like the other two: about 1.5 s of recording plus the stop; no threads of its own.
🤖 Generated with Claude Code