Repository navigation
callback: Accept exact fits in calldata buffers (split from #1464) - #1552
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #1464 (commit 72a2e4e). Part of breaking that 20-fix PR into small reviewable PRs.
What and why
cd_ensure_capacityreturned "fits" only whennew_size < capacity.new_sizealready includes the terminating size field, so a write that needs exactlycapacitybytes fits. The strict check: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;Fix:
<=inlibobs/callback/calldata.c.hand in the Rust portobs-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_calldata.cexact_capacity_grows_test→exact_capacity_fits_test(+ Rust mirror)test_calldata.cfixed_stack_testexact buffer (+ Rust mirror)sizeof(size_t),get_intfailsfixed_stack_testoverflow casebigger= 8+1 bytes refused (one spare byte unusable)bigger= 8+2 bytes (one past capacity) still refused, error logged, old value keptparity.rsexact_fit_and_past_double_match_oracle,fixed_stack_matches_oraclesizeof(usize)needed(C and Rust still compared byte-for-byte)RED → GREEN
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 cmockatest_calldatachanges fail the same way against master's C../lintok. Tier 2 (cmocka) left to PR CI.Checklist
masterdocs/features.mdline added (Stability)