Skip to content

quality: Miri, sanitizers and an unsafe-code lint for the Rust ports #143

Open

Description

@zackees

The policy says the safe core has no unsafe, but nothing enforces it: there is already unsafe { CStr::from_ptr } in the safe core at rust/obs-util/src/config_file.rs:949 with no // SAFETY: comment. Rust-allocated memory is freed by C (darray via bmalloc), and only three cmocka tests run with ASan/UBSan.

Work:

  • #![deny(unsafe_code)] on safe-core modules (forbid outside src/ffi/); fix config_file.rs:949.
  • clippy::undocumented_unsafe_blocks for ffi/.
  • Miri on the Tier 1 suites that don't call C.
  • An ASan/UBSan variant of the Tier 2 ON build.

Activity

  1. added
    enhancement
    quality
    on Oct 10, 2026
  2. zackees commented on Oct 11, 2026

    @zackees
    MemberAuthor

    Claiming: An ASan/UBSan variant of the Tier 2 ON build

    1. infra/sanitizer-workflow: a workflow_dispatch workflow (.github/workflows/sanitizers.yaml) plus rust/tools/sanitize/. It builds the tree under ASan+UBSan, TSan or valgrind, with ENABLE_RUST_LIBOBS OFF or ON as an input, runs every cmocka test, and does a timed headless OBS launch. A triage script writes the OBS-attributable reports to the job summary. PR today.

    The manual passes over master have already filed #128, #133 and #160. The Miri and unsafe lint items stay unclaimed.

  3. added
    claimed
    on Oct 11, 2026
  4. MCPVOT commented on Oct 12, 2026

    @MCPVOT
    Contributor

    Claiming: #![deny(unsafe_code)] on the safe-core modules, plus the unsafe lint for ffi/ (both were noted as unclaimed here; the Miri and sanitizer items stay with their current owners).

    Plan, as one PR, following the policy's RED→GREEN order:

    1. Deny unsafe_code for the four port crates (obs-util, obs-codec, obs-graphics, obs-media-io), allowing it back only on src/ffi/ and on the two Windows platform modules that call Win32 directly (obs_util::pipe::windows, obs_util::utf8::windows), each with its own reason next to the module declaration. RED commit: with only the denial in place, cargo check --workspace reports 10 E0133 errors, at config_file.rs:949 and profiler.rs:17, 105, 111, 115, 117, 137, 142, 495, 504.

    2. GREEN: clean up those two safe cores.

      • config_file::get_string was not only a lint violation: it read the value back through the address config_get_string returns after dropping the lock, so a concurrent writer that replaced the value frees the buffer and the safe API reads freed memory. It copies the bytes with the lock held now; the bytes returned do not change.
      • profiler's core loses the blog declaration, the bmalloc adoption and the box drop. profile_end reports the two LOG_ERROR lines through a callback the shim implements, which is the split the pipe port (rust: Port util/pipe-windows.c to obs-util #259) already uses for a failed CreateProcessW. Tier 1 gains a case for those lines that cmocka cannot see.
    3. Record the invariant in docs/rust-port/testing-policy.md.

    RED, GREEN and the local runs are done; the PR follows in a moment. Note on evidence: this machine has rustc 1.97.1 (windows-gnullvm) against the pinned 1.98.1, no soldr and no Docker, so I ran the equivalent commands directly (cargo test --workspace --ignore-rust-version, clippy -D warnings, fmt --check) and the head is deliberately unstamped so CI runs everything.

    The clippy::undocumented_unsafe_blocks half of item 2 is a much larger, separate change (about 40 ffi/ modules and several hundred blocks), so I left it out of this PR. Say the word if you would rather have it folded in or split per crate.

    Please add the claimed label; I have no triage rights on this repo.

  5. removed
    claimed
    on Oct 15, 2026
  6. github-actions commented on Oct 15, 2026

    @github-actions

    Claim bot: claim expired: no progress from @MCPVOT in 48 h. Anyone may claim it now.

  7. MCPVOT commented on Oct 20, 2026

    @MCPVOT
    Contributor

    Done and merged: the safe-core deny(unsafe_code) work landed in #290 ("rust: Deny unsafe_code in the port crates"), which merged on 2026-10-12. The lint that also caught the real bug in rust/obs-util/src/profiler.rs (a use-after-free on a reallocated Vec) is in that same PR.

    The claim expired because I did not comment here after the merge, so the bot released the item to anyone. Nothing is outstanding on my side for that part.

    Leaving the Miri and the ASan/UBSan Tier 2 variant with their current owners (zackees claimed the sanitizer workflow above).

  8. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Triage: a multi-item checklist, so labelling it tracker. Item 1 (deny unsafe_code) landed in #290; clippy undocumented_unsafe_blocks, Miri and the ASan/UBSan Tier 2 variant remain. Each should become its own sub-issue when someone picks it up.

  9. added
    tracker
    on Oct 25, 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

    enhancementqualitytracker

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions