Skip to content

libobs: Make obs_shutdown a no-op without a core - #1060

Merged
zackees merged 2 commits into
masterfrom
fix/1032-shutdown-after-failed-video
Oct 16, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/1032-shutdown-after-failed-video

Conversation

@zackees

@zackees zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Fixes #1032.

Bug: a failed obs_startup() shuts the core down itself and leaves obs NULL. A caller whose error path also calls obs_shutdown() then dereferenced the freed core (obs->source_types) and segfaulted. On Linux obs_startup() fails when its X11 hotkey connection can't be opened, which happened transiently in Tier 2 runs: that's the test_media_restart_stale_frame segfault after "Freeing OBS context data" listed on #838 (there was no video settings reset in those cases, i.e. startup, not video, had failed).

RED (test: obs_shutdown after a failed obs_startup must not crash): test_shutdown_after_failed_startup points DISPLAY at a display with no X server, asserts that obs_startup() fails, then calls obs_shutdown(). Local Tier 2: Freeing OBS context data then Test failed with exception: Segmentation fault(11), the flake's exact signature.

GREEN (libobs: Make obs_shutdown a no-op without a core): obs_shutdown() returns early when there is no core, like obs_reset_video() already does. obs.c is not ported, so this covers both builds.

Local Tier 2 (--repeat 3 --tests test_shutdown_after_failed_startup): 256/256 OFF and ON, the new test 3 more times in each. ./lint ok.

The diagnosis took two wrong turns, both corrected on #1032: "Unable to open X display" turned out to be harmless log noise, and a first repro "passed" only because its obs_startup failed and the test skipped.

A failed obs_startup() shuts the core down itself and leaves no core;
the media tests' error path then calls obs_shutdown() again, which
dereferences the freed core (obs->source_types). On Linux obs_startup
fails when the X11 hotkey connection cannot be opened; pointing DISPLAY
at a display with no X server forces that every time. This is the
segfault after "Freeing OBS context data" in test_media_restart_stale_frame.

Refs #1032
A failed obs_startup() shuts the core down itself and leaves obs NULL.
A caller whose error path also calls obs_shutdown() (the media cmocka
tests do; so may any app) then dereferenced the freed core in
obs_shutdown() (obs->source_types) and segfaulted. Return early when
there is no core, as obs_reset_video() and friends already do.

Fixes #1032
@zackees
zackees enabled auto-merge October 16, 2026 09:40
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit 2bc996f Oct 16, 2026
25 checks passed
@zackees
zackees deleted the fix/1032-shutdown-after-failed-video branch October 26, 2026 15:43
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: libobs: obs_shutdown() segfaults when called after obs_startup() failed

1 participant