Repository navigation
libobs: Make obs_shutdown a no-op without a core - #1060
Merged
Merged
Conversation
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
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 #1032.
Bug: a failed
obs_startup()shuts the core down itself and leavesobsNULL. A caller whose error path also callsobs_shutdown()then dereferenced the freed core (obs->source_types) and segfaulted. On Linuxobs_startup()fails when its X11 hotkey connection can't be opened, which happened transiently in Tier 2 runs: that's thetest_media_restart_stale_framesegfault after "Freeing OBS context data" listed on #838 (there was novideo settings resetin 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_startuppointsDISPLAYat a display with no X server, asserts thatobs_startup()fails, then callsobs_shutdown(). Local Tier 2:Freeing OBS context datathenTest 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, likeobs_reset_video()already does.obs.cis 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../lintok.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_startupfailed and the test skipped.