Repository navigation
libobs, frontend: Don't crash on a NULL output id in Settings - #219
Merged
Merged
Conversation
zackees
force-pushed
the
fix/217-output-null-id
branch
from
October 11, 2026 08:02
12a3c6f to
21c02f2
Compare
Member
|
Verified locally, rebased onto master and stamped.
As with #207, CI has no display, so this test only guards anything where Xvfb is available. Merging once CI is green. |
9 tasks done
Collaborator
Author
|
Same macOS cause as described in #218 (the new obs-studio-rust tag breaks version parsing on macOS); not from this change. |
obs_get_output_supported_video_codecs(NULL) and the other id-keyed output getters reach find_output(), which runs strcmp() on the id. The Settings window passes NULL there when no registered output supports the stream protocol, which crashes OBS (obsproject/obs-studio#12843, reported by HanabishiRecca). The test registers one output type, then calls each getter with NULL in a forked child and expects the not-found value instead of a crash. Refs obs-rust#217. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When no registered output supports the stream protocol, obs_enum_output_types_with_protocol() never calls back, and the Settings window passed its uninitialized `output` pointer (in practice NULL) to obs_get_output_supported_video/audio_codecs(). find_output() then ran strcmp() on it and OBS crashed while opening Settings (obsproject/obs-studio#12843, reported by HanabishiRecca). Initialize the frontend's output id to nullptr, and make find_output() treat a NULL id as not found so every id-keyed output getter returns its not-found value instead of crashing. The frontend already handles a NULL codec list by not filtering encoders. Fixes obs-rust#217. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=bfd01413d2e2181540fe7c1d543605f8fcf4b94e secs=139 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791707559,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f487ee6ddd2034f123e07ec0be5332e6c7110ac789e9d66d148c12a346bf7808","lane":"lint","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"e994bdf6dbb1567af2f64d6c4079e2f5","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"} Ci-Attestation: {"at":1791707559,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f487ee6ddd2034f123e07ec0be5332e6c7110ac789e9d66d148c12a346bf7808","lane":"lint","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"160692bcdd3ad07573f6fde4c3b8491c","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"} Ci-Attestation: {"at":1791707559,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"bb313a18e33e93c590f3d3d37b54eb0c722b9a7db3be29b908c54ff5c8477ea8","lane":"rust-test","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":33,"stamp":"80dc336476ed8ac953c0273373445133","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"} Ci-Attestation: {"at":1791707559,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"6232872e9547a08b8ba4ec77a9f3ecb04cc0fa21633c9197d34edfcee2aa51f7","lane":"tier2-linux","parents":["0a800516cdf38a05cba21de15c942c436c40d0e5"],"secs":53,"stamp":"d5b27c3d34bdd3aa1902e1cc7e1ffea0","tree":"bfd01413d2e2181540fe7c1d543605f8fcf4b94e","v":1,"via":"run"}
zackees
force-pushed
the
fix/217-output-null-id
branch
from
October 11, 2026 08:32
21c02f2 to
646a19a
Compare
9 tasks done
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.
Description
Opening Settings crashed OBS when no registered output supports the stream protocol (for example when no output plugin is loaded, or the stream service uses a protocol no output handles). With this change Settings opens normally in that case, and the id-keyed output getters in libobs return their not-found value for a NULL id instead of crashing.
The cause:
OBSBasicSettings::ServiceAndVCodecCompatible(),ServiceAndACodecCompatible()andResetEncoders()declareconst char *output;without initialising it (frontend/settings/OBSBasicSettings_Stream.cpp:1545,:1580,:1749,:1757) and fill it fromobs_enum_output_types_with_protocol(). When no output matches, the callback never runs and the pointer stays uninitialised (NULL in practice), and it is passed toobs_get_output_supported_video_codecs()/obs_get_output_supported_audio_codecs(). Those callfind_output()(libobs/obs-output.c:122), which runsstrcmp()on the id (obs-output.c:126) and crashes. That matches the report's backtrace (find_output (id=0x0)fromResetEncoders).test: Pin output getters crashing on a NULL id:test_output_null_idregisters one output type, then calls each id-keyed getter (obs_get_output_supported_video_codecs,obs_get_output_supported_audio_codecs,obs_get_output_flags,obs_output_get_display_name,obs_output_defaults,obs_get_output_properties) with NULL, each in a forked child, and expects the not-found value. 6 of 7 fail on this commit (the child crashes with signal 11). The control,registered_output_still_found, passes. It needs a display forobs_startupand skips without one, liketest_audio_io.libobs, frontend: Don't crash on a NULL output id in Settings:find_output()treats a NULL id as not found, and the four frontendoutputpointers are initialised tonullptr. The frontend already handles a NULL codec list by not filtering the encoders. All 7 tests pass.Motivation and Context
Fixes #217 (upstream obsproject/obs-studio#12843, reported by HanabishiRecca)
Why this one: it's a crash on opening Settings, so a user in this state can't get into Settings to fix the setup that caused it. The reporter already found the cause, the fix is small, and there is no upstream fix. It also stops reading an uninitialised pointer, which is undefined behaviour whatever its value.
How Has This Been Tested?
Automated:
test_output_null_idfails 6 of 7 at the RED commit and passes 7 of 7 at the GREEN commit, after clean rebuilds, under a private Xvfb. clang-format and gersemi are clean.By hand, headless: I ran the full frontend under a private X server with a profile crafted so that no registered output supports its stream protocol. Before the fix, opening Settings crashed with the reporter's exact stack (
strcmpinfind_output (id=0x0)fromOBSBasicSettings::ResetEncoders). After the fix, Settings opens.Not tested:
Types of changes
Checklist:
🤖 Generated with Claude Code