Skip to content

libobs: send an output's stop signal once when it is stopped again during its destroy (#3799) - #4843

Merged
vpacher merged 2 commits into
masterfrom
fix/3799-double-stop
Nov 13, 2026
Merged

vpacher merged 2 commits into
masterfrom
fix/3799-double-stop

Conversation

@vpacher

@vpacher vpacher commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

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) → glibc abort()

Older source-record versions (before 0.5.0) force-stop their recording output. Their stop handler queues the output's release and frees the handler's data, but never disconnects the handler. So they are safe only if stop comes once.

The end of capture added for #3764 (5f71441ee, the hang at exit, #3739) runs in obs_output_actual_stop() for an encoded output that never got a packet. It also ran on the second stop that obs_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 of obs_output_end_data_capture, which sends stop again. 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 sends stop once 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 second stop.

docs/features.md: one entry.

Tests

RED ef50349d7: force_stop_and_release_signal_stop_once in test_output_stop_without_packets. It does what source-record does: a stop handler that stays connected, a force stop of an encoded output that never got a packet, and a release as soon as the first stop arrived. It expects one stop signal. 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

vpacher and others added 2 commits November 13, 2026 11:49
…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 vpacher changed the title test: a force stop and a release right after its stop signal send stop once (#3799) libobs: send an output's stop signal once when it is stopped again during its destroy (#3799) Nov 13, 2026
@vpacher
vpacher marked this pull request as ready for review November 13, 2026 12:43
@vpacher
vpacher requested a review from zackees as a code owner November 13, 2026 12:43
@vpacher
vpacher added this pull request to the merge queue Nov 13, 2026
Merged via the queue into master with commit 3e5f397 Nov 13, 2026
42 checks passed
@vpacher
vpacher deleted the fix/3799-double-stop branch November 13, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: live multi-source conference sessions repeatedly crash on Arch Linux (#3710)

1 participant