Skip to content

callback: Accept exact fits in calldata buffers (split from #1464) - #1552

Merged
zackees merged 2 commits into
masterfrom
fix/calldata-exact-fit
Oct 20, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/calldata-exact-fit

Conversation

@zackees

@zackees zackees commented Oct 20, 2026

Copy link
Copy Markdown
Member

Split from #1464 (commit 72a2e4e). Part of breaking that 20-fix PR into small reviewable PRs.

What and why

cd_ensure_capacity returned "fits" only when new_size < capacity. new_size already includes the terminating size field, so a write that needs exactly capacity bytes fits. The strict check:

  • made a fixed calldata stack (calldata_init_fixed, used by signal handlers with stack buffers) refuse a parameter that exactly fills it: it logged "Tried to go above fixed calldata stack size!" and dropped the value;
  • made a heap calldata reallocate (to double) on an exact fit.

Fix: <= in libobs/callback/calldata.c.h and in the Rust port obs-callback::calldata::ensure.

This deliberately changes characterization tests, following the precedent of #1508 (the C-test expectation change was approved by the maintainer as in #1508). Assertions are made stricter, not weaker; comments say the old characterization is superseded and why. C and Rust change together.

Test Old expectation ("characterized, not endorsed") New expectation
test_calldata.c exact_capacity_grows_test → exact_capacity_fits_test (+ Rust mirror) exact fit grows capacity 128 → 256 capacity stays 128, both params read back
test_calldata.c fixed_stack_test exact buffer (+ Rust mirror) exact fit refused, error logged, size stays sizeof(size_t), get_int fails accepted, no error, size == needed, value 5 reads back, param layout + terminator checked
fixed_stack_test overflow case bigger = 8+1 bytes refused (one spare byte unusable) bigger = 8+2 bytes (one past capacity) still refused, error logged, old value kept
parity.rs exact_fit_and_past_double_match_oracle, fixed_stack_matches_oracle C capacity 256; exact size sizeof(usize) C capacity 128; exact size needed (C and Rust still compared byte-for-byte)

RED → GREEN

  • RED ed625ee: soldr cargo test -p obs-data --test obs-tests-core callback:: fails 4 (exact_capacity_fits_test, fixed_stack_test, fixed_stack_matches_oracle, exact_fit_and_past_double_match_oracle); the cmocka test_calldata changes fail the same way against master's C.
  • GREEN 5506d23: 56/56 callback tests pass; ./lint ok. Tier 2 (cmocka) left to PR CI.

Checklist

  • Base is master
  • RED, then GREEN commits
  • docs/features.md line added (Stability)
  • No intentional C/Rust difference remains (parity test compares both)

Supersedes the characterization in exact_capacity_grows_test and
fixed_stack_test (C and Rust): a write whose needed size equals the
capacity fits, because needed already includes the terminator.
Split from #1464.
cd_ensure_capacity grew (or, for a fixed stack, refused) when the needed
size equaled capacity. Use <= in the C and the Rust port.
Split from #1464 (72a2e4e).
@zackees
zackees enabled auto-merge October 20, 2026 20:13
@zackees
zackees added this pull request to the merge queue Oct 20, 2026
Merged via the queue into master with commit 7b7f229 Oct 20, 2026
23 checks passed
@zackees
zackees deleted the fix/calldata-exact-fit branch October 26, 2026 15:44
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.

1 participant