Repository navigation
util: Zero the video fields of a formatted filename with no video - #1562
Merged
Merged
Conversation
The characterization of os_generate_formatted_filename (obs-rust#262 slice 5) pinned a defect as "characterized, not endorsed": the result of obs_get_video_info is not checked, so with no video %FPS, %CRES, %ORES and %VF are formatted from whatever the call left in the struct. The real obs_get_video_info returns false without writing it, so the C reads uninitialized stack memory there; the Rust shim starts from a zeroed struct. This deliberately changes that characterization to expect the zeroed fields, since the next commit makes the C and the Rust shim honour the result: - video_info_read_test: the fixture returns false with non-zero fields (48 fps, 640x360, 320x180, NV12), and "%FPS %CRES %ORES %VF" must give "0 0x0 0x0 None" instead of "48 640x360" from "%FPS %CRES". - Its Tier 1 mirror video_info_read expects "0 0x0 0x0 None" from the zeroed fields the shim passes on with no video, instead of the fields as the call left them. - The Tier 3 parity test shim_matches_c checks the no-video case against that name on both sides, with and without spaces and for a plain name, instead of comparing the two as the call left them. On master, test_formatted_filename fails video_info_read_test, and the obs-util platform_filename tests fail shim_matches_c (30 of 31 pass). Refs obs-rust#1509
os_generate_formatted_filename read the video info with obs_get_video_info and ignored the result. With no video (before a successful obs_reset_video) that call returns false without writing the struct, so %FPS, %CRES, %ORES and %VF were formatted from uninitialized stack memory, giving names like 2880154539x2880154539. Zero the struct when obs_get_video_info returns false, in the C (libobs/util/platform-filename.c.h) and in the Rust shim (obs-util::ffi::platform_filename), so a missing video formats as 0, 0x0 and None. The Rust shim already started from a zeroed struct, but used whatever the call left in it. No caller in the tree reaches this: the recording outputs and the frontend format names with video up. A plugin or libobs-based tool that names a file before video is set up got a garbage name. Calling it before obs_startup still crashes in obs_get_video_info, as every libobs getter does; that precondition is unchanged. Upstream OBS has the same code in libobs/util/platform.c (no upstream issue). The Tier 3 parity test compares the Rust shim with the same C file, so both change together: its header no longer lists the uninitialized fields as an intentional difference, and rust/README.md no longer lists the unchecked result as kept. Refs obs-rust#1509
zackees
approved these changes
Oct 20, 2026
zackees
enabled auto-merge
October 20, 2026 21:12
Member
|
Coordinator: queued under the #1508 precedent. The only C-test change flips a case marked "characterized, not endorsed" (formatting video fields left unset when |
This was referenced Oct 20, 2026
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 21, 2026
It was merged with a literal #PR placeholder. The fix landed in obs-rust#1562 (zeroed video fields) and obs-rust#1565 (no crash before obs_startup). Refs obs-rust#1611
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 21, 2026
…ck (obs-rust#1612) * test: Start the output interleaver with slot 0 of the video encoders empty obs_output_set_video_encoder2() lets a multitrack video output leave slot 0 empty and use slot 1 or higher, and obs_output_can_begin_data_ capture() accepts that (video_valid() checks every slot). The start of the interleaver then never runs: prune_premature_packets() and get_interleaved_start_idx() look for the first video packet of track 0 only, find none, and the start is skipped. The next packet sees both received flags set and is sent as if started, with no offsets applied. The packets queued before the start keep the encoder's system-time dts_usec, so they sort after everything sent later and stay queued until the output stops: the first keyframe is never sent, and the output starts on a frame that is not a keyframe with timestamps that are not offset to 0. test_output_interleave_e2e runs its four cases again with the video encoder in slot 1 and slot 0 empty (the output is registered OBS_OUTPUT_MULTI_TRACK_AV so that slot 1 can be set; the slot 0 cases are unchanged). All four fail on master against libobs and libobs-with-rust: the first packet is audio, then video frame 1, not the keyframe of frame 0 at dts 0. The Tier 1 port gets the same two start cases on its model output. Refs obs-rust#1611 * libobs: Start the output interleaver on the first video encoder's track The interleaver's start follows the first video packet of track 0: prune_premature_packets() and get_interleaved_start_idx() look for it, and with slot 0 of the video encoders empty (a multitrack video output set up with obs_output_set_video_encoder2() and an index above 0, which obs_output_can_begin_data_capture() accepts) they never find one. The start was then skipped, the next packet was sent as if started, without offsets, and the packets queued before the start (the first keyframe among them) kept their system-time dts_usec, sorted after everything sent later, and stayed queued until the output stopped. The output started on a frame that is not a keyframe. Both now follow the track of the first video encoder, as initialize_interleaved_packets() already does (obs_output_interleave_first_video_encoder_index()). With slot 0 set, that is track 0, so nothing changes for those outputs. The C original and the Rust core get the same change, so the Tier 3 parity holds; the Rust pure functions take the track as an argument (the four Tier 1 calls pass 0). Fixes obs-rust#1611 * docs: Fill in the PR links of the obs-rust#1509 features line It was merged with a literal #PR placeholder. The fix landed in obs-rust#1562 (zeroed video fields) and obs-rust#1565 (no crash before obs_startup). Refs obs-rust#1611
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.
Refs #1509 (fixes the uninitialized fields; the crash before
obs_startupinobs_get_video_infois a libobs core change and follows as its own PR, so the issue stays open)What and why
os_generate_formatted_filenamenow formats%FPS,%CRES,%ORESand%VFas0,0x0,0x0andNonewhen there is no video. Before, it ignored the result ofobs_get_video_info, which returnsfalsewithout writing the struct when no video is set up, so those specifiers were formatted from uninitialized stack memory (names like2880154539x2880154539).libobs/util/platform-filename.c.h) zeroes the struct whenobs_get_video_inforeturnsfalse. The Rust shim (obs-util::ffi::platform_filename, ported in util: Port os_generate_formatted_filename to obs-util #1511) already started from a zeroed struct but used whatever the call left in it; it now passes zeroed fields when the call returnsfalse, so the C and the Rust give the same name.obs_startupstill crashes inobs_get_video_info, as every libobs getter does without a started core. That precondition is unchanged here; a!obscheck inobs_get_video_infowould be a separate libobs core change.libobs/util/platform.c. Nobody has reported it there, so there is no upstream issue.Changes an existing test (needs maintainer sign-off). The characterization from #262 slice 5 pinned the defect as "characterized, not endorsed". The RED commit changes the no-video case to expect the zeroed fields, since this PR fixes it:
test_formatted_filename'svideo_info_read_test: the fixture still returnsfalsewith non-zero fields (48 fps, 640x360, 320x180, NV12, standing in for what the real call leaves unset), and"%FPS %CRES %ORES %VF"now expects"0 0x0 0x0 None". Before,"%FPS %CRES"expected"48 640x360", the fields as the call left them.video_info_readexpects"0 0x0 0x0 None"from the zeroed fields, instead of"48 640x360"from the fields as the call left them.shim_matches_cchecks the no-video case against that name on both sides (with and without spaces, and a plain name), instead of only comparing the C and the Rust as the call left them.No other test changes.
Headless (private Xvfb, private D-Bus, fresh HOME):
test_formatted_filenamewith the RED test, libobs and libobs-with-rust, both lanesvideo_info_read_testfails ("48 640x360 320x180 NV12" != "0 0x0 0x0 None"), 16/17 passplatform_filenametests with the RED testsshim_matches_c)test_formatted_filename, libobs and libobs-with-rust, both lanesplatform_filenametests (Tiers 1 and 3)RED → GREEN
test: Expect zeroed video fields from a formatted filename with no video. On master,test_formatted_filenamefails 1 of 17 (video_info_read_test) in the C lane (ENABLE_RUST_LIBOBS=OFF) and the libobs-with-rust lane (ON), each against bothlibobsandlibobs-with-rust.cargo test -p obs-util --lib platform_filename: 30 passed, 1 failed.test_formatted_filename,test_platform*and the deque tests pass 7/7 in both lanes against both libraries); exported symbols of the two libraries identical (1766).cargo test -p obs-util: 706/706 after the rebase.cargo clippy -p obs-util --all-targets -- -D warnings: clean.uv run ci/local_gate.py --lane lint,cross,cross-release,rust-test: ok.Checklist
masterdocs/features.mdis added (Fixed upstream bugs, Encoding, streaming and recording)-W..., ratchets): built with scripting ON (a flag change under cmake/ or build-aux/ runs the full builds) and cross-checked with clang and MSVC (not applicable: no flag change)