Skip to content

obs-c-oracle: Fix the gif bench's pixel read - #2616

Merged
rdoupe merged 2 commits into
masterfrom
fix/2614-bug-obs-c-oracle-port-comparison
Oct 27, 2026
Merged

rdoupe merged 2 commits into
masterfrom
fix/2614-bug-obs-c-oracle-port-comparison

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2614

What and why

The port_comparison bench test (soldr cargo test -p obs-c-oracle --locked --bench port_comparison) segfaults on master in the gif module, added with the libnsgif port (#2514), so every module after it, and the per-module allocation check, never runs.

The issue suspected a failed decode leaving the bitmap NULL. It doesn't: with every libnsgif return checked, nsgif_create and all five nsgif_frame_decode calls return NSGIF_OK with a bitmap, on both the Rust and the C side, and the bench still faults. The fault is the bench's own read: nsgif_frame_decode hands back the bitmap handle that the bench's create callback made (a boxed Vec<u32>), and the bench read the last pixel by indexing that handle as if it were the pixel buffer, 8 MB past a 24-byte box. The fix reads the pixel through the bench's own get_buffer callback, as libnsgif does. The decoders are unchanged.

vpacher reached the same diagnosis independently on the issue, with an lldb trace on macOS: there the stray read is a SIGBUS, and in the bench profile (cargo bench) it lands in mapped, zeroed memory, so both sides read 0 and match, which is why the bench passed when the port was measured.

No upstream issue (the bench is obs-rust's own).

RED → GREEN

  • RED commit: 97e648b: every libnsgif call in both closures is checked (NSGIF_OK and a non-null bitmap); all checks pass and the bench test still dies with signal: 11, SIGSEGV: invalid memory reference right after Testing encoder_size/rate_route/1024/c.
  • GREEN: the bench test runs every module to the end and exits 0, with the per-module allocation check passing (gif/scan_decode_5x1080p rust and c both Success). uv run ci/local_gate.py --test-diff origin/master: 4370 passed, 6 skipped; --lane lint and --lane cross ok; Windows MSVC clippy (--all-targets -D warnings) clean. Runs were on f03572d; Tier 2 did not run locally (no Docker access on the build host) and is left to PR CI, which selects it only for libobs paths.
  • Real app (UI, protocol output or logging changes): N/A, bench-only change.

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): N/A, none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): N/A, not a port

The gif bench pair ignored the results of nsgif_create() and
nsgif_frame_decode(), so a failed decode would leave the bitmap NULL
and fault on the pixel read. Assert NSGIF_OK and a bitmap on both
sides, and read the last pixel through one helper.

Every call now returns NSGIF_OK with a bitmap, and the bench still
faults: the read itself is wrong, which the next commit fixes.

Refs #2614.
nsgif_frame_decode() hands back the bitmap the bench's create callback
made, a boxed Vec<u32>, and the bench indexed that handle as if it
were the pixels, reading 8 MB past a 24-byte box. The decode never
failed. Read the last pixel through get_buffer, as libnsgif does, so
the port_comparison bench test runs past the gif module again.

Fixes #2614.
@rdoupe
rdoupe force-pushed the fix/2614-bug-obs-c-oracle-port-comparison branch from 8ff485a to f03572d Compare October 27, 2026 12:26
@rdoupe
rdoupe marked this pull request as ready for review October 27, 2026 12:36
@rdoupe
rdoupe requested a review from zackees as a code owner October 27, 2026 12:36
@rdoupe
rdoupe added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 6c31f3a Oct 27, 2026
31 checks passed
@rdoupe
rdoupe deleted the fix/2614-bug-obs-c-oracle-port-comparison branch October 27, 2026 12:55
@rdoupe rdoupe mentioned this pull request Oct 27, 2026
6 of 7 tasks
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-c-oracle: port_comparison gif bench dereferences a NULL frame

1 participant