Skip to content

bug: obs-util: dstr_safe_printf one-pass port leaves a different capacity than C, so dstr_ops_match_c fails intermittently #1623

Closed

Description

@rdoupe

Since #1619 (one-pass dstr_safe_printf), the obs-util Tier 3 proptest tests::strings::dstr_parity::dstr_ops_match_c fails intermittently on master and on unrelated PRs (seen on #1622's Fast Gate, run 39622049384). The proptest picks random inputs, so it passes on some runs and fails on others.

Minimal failing input (from proptest shrinking)

ops = [SafePrintf(Some(b"$1"), [Some(b"\x01\x01\x01"), None, None, None])]

Both sides produce the same string ("\x01\x01\x01", NUL-terminated), but the buffer capacity differs:

left:  Snap { null: false, bytes: [1, 1, 1], terminator: Some(0), capacity: 4 }
right: Snap { null: false, bytes: [1, 1, 1], terminator: Some(0), capacity: 6 }

(rust/obs-util/tests/strings/dstr_parity.rs:209)

Cause

C's dstr_safe_printf copies the format and then runs dstr_replace once per value, so its final capacity follows the growth of those steps. The one-pass Rust version writes the result once and allocates a different capacity. The contents are identical, and there is no memory-safety issue. The parity test compares capacity, so the Rust allocation has to follow the same growth rule (or the parity contract for capacity has to be stated differently, which would be a policy change).

Fix

Make the one-pass writer reserve the capacity the C passes end with, and add the shrunk case as a fixed Tier 3 regression so the proptest can't hide it.

Activity

  1. rdoupe commented on Oct 21, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #1623. One PR: RED with the shrunk case as a fixed Tier 3 regression, then GREEN making the one-pass writer reserve the capacity C ends with. Today.

  2. added
    claimed
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions