Repository navigation
Description
What happens
shader::effect_parser_writer_parity::called_functions (rust/obs-graphics/tests/shader/effect_parser_writer_parity.rs, from the writer port in #3769) fails now and then: proptest finds a case where the Rust writer and the C writer write different shader strings. It failed in a local ./unittest run on a branch that changes no Rust and none of the writer's C.
minimal failing input: Model { params: [MParam { ty: [97], name: [97], is_const: false, is_uniform: false, count: 1, written: false }], structs: [], funcs: [MFunc { name: [97], ret: [97], mapping: None, contents: [123, 125], .. }], samplers: [], call: Some([([97], 0), ([40], 0), ([41], 0)]), prefix: Some(([0], 0)) }
left (Rust): "\0a a[1];\na a()\n{}\n\na main()\n{\n\treturn a();\n}\n" len 44
right (C): ";\na a()\n{}\n\na main()\n{\n\treturn a();\n}\n" len 37
seed: cc d775b1a919540b7ca0889e7c0df1132e1a8ae4d48a25c4a412302bcd64a9f1ad
Why
The model's prefix, the text already in the caller's struct dstr before ep_makeshaderstring() appends to it, is generated from any bytes (effect_parser_writer_parity.rs ~290):
prop::option::weighted(0.2, (prop::collection::vec(any::<u8>(), 1..6), 0usize..8)),so it can hold a NUL byte while len counts past it. A 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 that (here the C's result loses the a a[1] it wrote after the NUL). The compile step always passes an empty dstr, so no real input reaches this; the difference is the generator's, not the writer's.
Proposed fix
Generate prefix bytes without NUL (prop::collection::vec(1u8..=255, 1..6)), keeping the prefix's other cases, and check the case above passes. Neither writer changes.
Test
The seed above fails on master today; with the generator fixed, the same model can no longer be generated, and called_functions and random_parsers pass at the full case count.
Activity
rdoupe commentedon Nov 7, 2026
Claiming: the writer parity test's NUL-bearing dstr prefix
1u8..=255, keeping the prefix's length, spare capacity andNonecases. Neither writer changes.called_functionsandrandom_parsersat the full case count, plus the usual local gates.PR expected within a few hours.
test: Check the writer parity prefix has no NUL
test: Keep NULs out of the writer parity prefix
test: Keep NULs out of the writer parity prefix (obs-rust#3811)
rdoupe commentedon Nov 7, 2026
Fixed by #3811 (merged through the merge queue). The writer parity test now draws its dstr prefix bytes from 1..=255, so a prefix can no longer hold a NUL while the length counts past it; a new test,
prefix_is_dstr_text, checks 20,000 prefixes from a fixed seed. Neither writer changed, because the difference came from the test's generator and not from the writers; real input never reaches it, since the compile step passes an empty dstr.Left: nothing. There is no follow-up issue.