Skip to content

test: Keep NULs out of the writer parity prefix - #3811

Merged
rdoupe merged 2 commits into
masterfrom
fix/3802-bug-obs-graphics-writer-parity-t
Nov 7, 2026
Merged

rdoupe merged 2 commits into
masterfrom
fix/3802-bug-obs-graphics-writer-parity-t

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3802

What and why

The effect parser writer parity test (shader::effect_parser_writer_parity) can start the shader string with text already in it. That prefix was generated from any bytes, so now and then it held a NUL byte while the dstr's len counted past it. A struct dstr never looks like that (its len is the length of its text up to the terminating NUL), and the dstr helpers the C writer calls rely on it, so proptest occasionally reported a Rust/C mismatch in called_functions or random_parsers that came from the generator, not from either writer. The compile step always passes an empty dstr, so no real input reaches this.

This draws prefix bytes from 1u8..=255, keeping the prefix's length range, spare capacity and its None case, and adds prefix_is_dstr_text, which draws 20,000 prefixes from a fixed seed and fails if any holds a NUL. Neither writer changes. The failing model from the issue can't be pinned as a regression case: the writers really do differ on it, and with the fix the generator can no longer make it. No upstream issue.

RED → GREEN

  • RED commit: 20b605a (test: Check the writer parity prefix has no NUL). shader::effect_parser_writer_parity::prefix_is_dstr_text fails: prefix [15, 6, 0, 209, 165] holds a NUL; the module's other tests pass. --lane lint passes and --test-diff origin/master fails only that test.
  • GREEN: the module passes 40 of 40 runs at the full case count (no proptest seed file written). With only the generator line reverted, the parity tests first failed on the 5th of 40 runs (called_functions and random_parsers, both shrinking to a [0] prefix). --test-diff: 6382 passed, 6 skipped; ./unittest: Rust 6744 passed, 6 skipped, and 912 passed, Tier 2 747/747 on both builds; --lane lint and --lane cross pass; MSVC clippy --workspace --all-targets -D warnings is clean; the local gate stamped the head (lint, rust-test, cross, tier2-linux). No C, libobs or export changes.
  • Real app (UI, protocol output or logging changes): not applicable (test generator only).

Runs were on d443f04 (RED, before the rebase onto current master), e83528a97 (GREEN: the 40-run loop, --test-diff) and e11ceb6 (GREEN after the rebase: ./unittest, the lanes, the Windows clippy and the stamp).

Test cost: one new test, longest 8 ms, peak RSS 6.2 MB over 5 runs, no own threads.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: not a port; no new difference)

The writer parity test's model can start the shader string with text
already in it, generated from any bytes, so it can hold a NUL byte while
the dstr's len counts past it. A dstr never looks like that, and the C
writer's dstr helpers rely on it: proptest then finds a case where the
two writers' strings differ by the generator, not the writer.

Move the prefix strategy into its own function and check, drawing from
a fixed seed, that it never makes a prefix holding a NUL. It fails on
the current generator every run.

Refs #3802.
Draw the prefix's bytes from 1..=255, keeping its length range, spare
capacity and None case, so the shader string the writers append to is
always a valid dstr. Neither writer changes; the compile step always
passes an empty dstr, so no real input reached the difference.

Over 40 runs of the module the old generator first failed
called_functions and random_parsers on the 5th; with this, all 40 pass.

Fixes #3802.

Local-Gate: v1 tree=598c0a750d9a9bc4e394c848f2bf4ce8f5027748 secs=2206 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794033285,"gate":"rust/all/fmt","host":"linux-x86_64","key":"71d4f449b370a5fd66085a37efb5e696057826be30218237586fc21eb8262e58","lane":"lint","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":50,"stamp":"f6fc2c6f441294f5f3cd133cb55ddfd7","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"71d4f449b370a5fd66085a37efb5e696057826be30218237586fc21eb8262e58","lane":"lint","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":50,"stamp":"ef5306c0dd020526ec6c0cf9445f6aa7","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"fd20930d309444f1274cc74d669dbb15aa5916a382298ddf6ef531ad25504d06","lane":"rust-test","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":111,"stamp":"f8eea67e13d62a58decdc8548a8c3de7","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"5fd1fdfa3352a8d678730601ecf6829ca648247eff6a14084acd84479448d78d","lane":"cross","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":62,"stamp":"9f1bec0bfb311ed6b2a9ed112bec8066","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"5fd1fdfa3352a8d678730601ecf6829ca648247eff6a14084acd84479448d78d","lane":"cross","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":62,"stamp":"98ecf73c2fdf7092c15eb9fa4d27b01d","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"5fd1fdfa3352a8d678730601ecf6829ca648247eff6a14084acd84479448d78d","lane":"cross","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":62,"stamp":"bf88fc6089fa92dbfcea3d8c5aede229","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"5fd1fdfa3352a8d678730601ecf6829ca648247eff6a14084acd84479448d78d","lane":"cross","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":62,"stamp":"6bc31eaa8ff14dc572ecc40cc439f3f7","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
Ci-Attestation: {"at":1794033285,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5fa774bf99b57add8160684d2db211330eda8dabf80550fb73e8024f2dd2bff2","lane":"tier2-linux","parents":["20b605af7d1ac3ef92886db199213ece800bccf3"],"secs":2206,"stamp":"a80c3019e34ef5a7b6d91800c7ff89d9","tree":"598c0a750d9a9bc4e394c848f2bf4ce8f5027748","v":1,"via":"run"}
@rdoupe
rdoupe force-pushed the fix/3802-bug-obs-graphics-writer-parity-t branch from d443f04 to e11ceb6 Compare November 7, 2026 06:35
@rdoupe
rdoupe marked this pull request as ready for review November 7, 2026 07:01
@rdoupe
rdoupe requested a review from zackees as a code owner November 7, 2026 07:01
@rdoupe
rdoupe added this pull request to the merge queue Nov 7, 2026
@rdoupe

rdoupe commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Handed off to the coordinator

Merged via the queue into master with commit 551a647 Nov 7, 2026
39 checks passed
@rdoupe
rdoupe deleted the fix/3802-bug-obs-graphics-writer-parity-t branch November 7, 2026 07:18
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to Done in obs-rust Multiview Nov 7, 2026
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: obs-graphics: writer parity test feeds a dstr with a NUL

1 participant