Skip to content

Fix arith_offset for zero-sized pointees - #5202

Open
v3risec wants to merge 1 commit into
model-checking:mainfrom
v3risec:fix/zst-arith-offset
Open

v3risec wants to merge 1 commit into
model-checking:mainfrom
v3risec:fix/zst-arith-offset

Conversation

@v3risec

@v3risec v3risec commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve the original pointer when arith_offset has a zero-sized Rust pointee. On the CBMC 6.11.0 SMT path, the old pointer addition can change the modeled address for an over-aligned ZST.

Changes

  • Use Rust's pointee layout to select the zero-size case, then retain the pointer value and its provenance.
  • Evaluate both call operands in order. A projected offset operand can read memory even when its value has no effect on the address.

Validation

Tested commit cb10fb8 on upstream main c25a57bc.

  • The CVC5 live-allocation regression fails its address check on upstream main and passes with the fix. It also checks a literal zero offset, allocation identity, and write-back.
  • All three ArithOffset regression files pass.
  • The explicit MIR operand test reports a null pointer dereference. Removing operand evaluation makes that test incorrectly verify.

Related to #3589 and #4671.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

Return the original pointer when a Rust pointee has zero size. Evaluate the pointer and offset in order so projected operand reads retain their checks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants