You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs: obs_shutdown() segfaults when called after obs_startup() failed #1032
Seen in a local Tier 2 run (OFF build, 2026-10-16 ~07:30Z) in test_media_restart_stale_frameclear_still_clears, listed on #838 as a flake. The log shows it is not timing:
info: Unable to open X display
info: Freeing OBS context data
[ ERROR ] --- Test failed with exception: Segmentation fault(11)
[ FAILED ] clear_still_clears
The test's init_core() (test/cmocka/test_media_restart_stale_frame.c:134) calls obs_startup then obs_reset_video; the latter failed (the X server under xvfb-run -a was not reachable for that one case, the previous case in the same binary passed). run_script then does the right thing, obs_shutdown(); skip(); (:413-415), and the crash happens inside that obs_shutdown() ("Freeing OBS context data" is printed by it, the segfault right after).
Class
Crash in teardown after a failed video init. Any caller that handles an obs_reset_video failure and shuts down cleanly (an app on a machine whose GPU/display fails, or a test) crashes instead of exiting.
Next steps
Failing test: obs_startup, obs_reset_video with an unreachable display (e.g. DISPLAY=:9999, or a bogus graphics_module), expect a non-success result, then obs_shutdown(): must not crash. Run in the Tier 2 container.
Find which teardown step touches state the failed reset left half-initialized (graphics thread, video output, or canvas), and guard it.
Refs #838 (this entry there is a crash, not load sensitivity).
Seen again (ON build, ~08:10Z): clear_then_frame_unbuffered segfaulted after "Unable to open X display". The trigger is Xvfb intermittently unreachable under parallel ctest (noted on #838); the crash in obs_shutdown() after a failed obs_reset_video() is the libobs bug this issue tracks.
Claiming: RED test (obs_startup, obs_reset_video against an unreachable DISPLAY so it fails deterministically, then obs_shutdown must not crash), then find and guard the teardown step.
Update: my first reproduction does not crash. DISPLAY=:9999, obs_startup, obs_reset_video (fails as expected), obs_shutdown passes in Tier 2 (branch fix/1032-shutdown-after-failed-video, commit ea1ad596f). So "shutdown after any failed video reset" is not the bug.
What the failing logs actually show is "Unable to open X display", then Freeing OBS context data, then the segfault. "Unable to open X display" can also come from obs_startup's X11 hotkey/platform setup, so in the real failures the X connection may have failed in one place but not another (e.g. hotkeys lost the display while graphics came up), which a dead :9999 can't produce. The crash is late in or after obs_shutdown. Next: get a backtrace by running test_media_restart_stale_frame with the display dropped mid-start (or under catchsegv/gdb in the Tier 2 container), instead of guessing further. Keeping the claim.
Correction to my earlier comment: "Unable to open X display" is not evidence that Xvfb was unreachable. It is printed by obs_nix_x11_log_info() (libobs/obs-nix-x11.c:39) whenever obs_get_nix_platform_display() is NULL, i.e. whenever nothing called obs_set_nix_platform_display(), which only the frontend does. Every cmocka test that calls obs_startup logs it, including passing ones (the next test_v4l2_busy_signal case logged it and then registered X11 hotkey keycodes fine). So the "Xvfb dropping out under parallel ctest" explanation I gave is wrong and should be disregarded; the cause of these failures is still unknown. For this issue: the segfault after Freeing OBS context data is real, but I don't yet know what precedes it; next step is still a backtrace.
Found it. The crashes are obs_shutdown() after a failed obs_startup(), not after a failed video reset. In the crashing cases the log is CPU info, "Unable to open X display" (harmless, see above), then Freeing OBS context data with no video settings reset lines: that is obs_startup() failing and cleaning up after itself (it calls obs_shutdown() internally, libobs/obs.c:~1408, leaving obs NULL). The test's init_core() returns false and its error path calls obs_shutdown() again, which dereferences obs->source_types with no NULL check. On Linux obs_startup() fails when its X11 hotkey connection (XOpenDisplay in obs_nix_x11_hotkeys_platform_init) can't be opened, which is what happened transiently in those runs.
My earlier "passing" repro never tested this: with DISPLAY=:9999 its obs_startup() failed and the test skip()ped, which cmocka counts as a pass. The new RED test asserts the startup failure instead and then calls obs_shutdown(). Fix: make obs_shutdown() a no-op without a core (if (!obs) return;), like obs_reset_video already does.
changed the title [-]bug: libobs: obs_shutdown() segfaults after obs_reset_video() failed (no X display)[/-][+]bug: libobs: obs_shutdown() segfaults when called after obs_startup() failed[/+]on Oct 16, 2026
Activity
zackees commentedon Oct 16, 2026
Seen again (ON build, ~08:10Z):
clear_then_frame_unbufferedsegfaulted after "Unable to open X display". The trigger is Xvfb intermittently unreachable under parallel ctest (noted on #838); the crash inobs_shutdown()after a failedobs_reset_video()is the libobs bug this issue tracks.zackees commentedon Oct 16, 2026
Claiming: RED test (obs_startup, obs_reset_video against an unreachable DISPLAY so it fails deterministically, then obs_shutdown must not crash), then find and guard the teardown step.
zackees commentedon Oct 16, 2026
Update: my first reproduction does not crash.
DISPLAY=:9999,obs_startup,obs_reset_video(fails as expected),obs_shutdownpasses in Tier 2 (branchfix/1032-shutdown-after-failed-video, commitea1ad596f). So "shutdown after any failed video reset" is not the bug.What the failing logs actually show is "Unable to open X display", then
Freeing OBS context data, then the segfault. "Unable to open X display" can also come fromobs_startup's X11 hotkey/platform setup, so in the real failures the X connection may have failed in one place but not another (e.g. hotkeys lost the display while graphics came up), which a dead:9999can't produce. The crash is late in or afterobs_shutdown. Next: get a backtrace by runningtest_media_restart_stale_framewith the display dropped mid-start (or undercatchsegv/gdb in the Tier 2 container), instead of guessing further. Keeping the claim.zackees commentedon Oct 16, 2026
Correction to my earlier comment: "Unable to open X display" is not evidence that Xvfb was unreachable. It is printed by
obs_nix_x11_log_info()(libobs/obs-nix-x11.c:39) wheneverobs_get_nix_platform_display()is NULL, i.e. whenever nothing calledobs_set_nix_platform_display(), which only the frontend does. Every cmocka test that callsobs_startuplogs it, including passing ones (the nexttest_v4l2_busy_signalcase logged it and then registered X11 hotkey keycodes fine). So the "Xvfb dropping out under parallel ctest" explanation I gave is wrong and should be disregarded; the cause of these failures is still unknown. For this issue: the segfault afterFreeing OBS context datais real, but I don't yet know what precedes it; next step is still a backtrace.zackees commentedon Oct 16, 2026
Found it. The crashes are
obs_shutdown()after a failedobs_startup(), not after a failed video reset. In the crashing cases the log is CPU info, "Unable to open X display" (harmless, see above), thenFreeing OBS context datawith novideo settings resetlines: that isobs_startup()failing and cleaning up after itself (it callsobs_shutdown()internally,libobs/obs.c:~1408, leavingobsNULL). The test'sinit_core()returns false and its error path callsobs_shutdown()again, which dereferencesobs->source_typeswith no NULL check. On Linuxobs_startup()fails when its X11 hotkey connection (XOpenDisplayinobs_nix_x11_hotkeys_platform_init) can't be opened, which is what happened transiently in those runs.My earlier "passing" repro never tested this: with
DISPLAY=:9999itsobs_startup()failed and the testskip()ped, which cmocka counts as a pass. The new RED test asserts the startup failure instead and then callsobs_shutdown(). Fix: makeobs_shutdown()a no-op without a core (if (!obs) return;), likeobs_reset_videoalready does.[-]bug: libobs: obs_shutdown() segfaults after obs_reset_video() failed (no X display)[/-][+]bug: libobs: obs_shutdown() segfaults when called after obs_startup() failed[/+]libobs: Make obs_shutdown a no-op without a core (obs-rust#1060)