Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crucible_llvm_verify produces too-complicated proof goals for isAllocated tests #587

Closed
brianhuffman opened this issue Nov 12, 2019 · 1 comment · Fixed by GaloisInc/crucible#338

Comments

@brianhuffman
Copy link
Contributor

Specifically, this refers to goals with names/descriptions that include "the region wasn't allocated". These goals contain terms which are essentially the saw-core translation of a cryptol expression like this:

(((4 * i <= 4 + 4 * i) /\ (4 <= 4 + 4 * i)) \/ (0 == 4 + 4 * i)) /\ (4 + 4 * i <= 400)

Here 400 is the size of the allocation, 4 is the size of the memory load or store, and 4 * i is the offset of the pointer. The formula is supposed to state that the sequence of addresses [4*i .. 4+4*i) lies entirely within the range [0 .. 400).

This is way too complicated. We should generate a much simpler formula instead.

@brianhuffman
Copy link
Contributor Author

I think it would suffice to check two properties:

  • The size of the load/store is no larger than the allocation size: size <= alloc_size
  • The offset of the pointer at least size bytes below the top of the allocation: offset <= alloc_size - size. Note that the first property ensures that the subtraction will not underflow.

So in the case of size = 4, alloc_size = 400, and offset = 4*i, we would have a proof obligation of

  (4 <= 400) /\ (4 * i <= 396)

which is a bit simpler than the one above. Furthermore, the first conjunct is usually a comparison of two concrete values and will simplify away.

brianhuffman pushed a commit to GaloisInc/crucible that referenced this issue Nov 12, 2019
Instead of
  ((off <= sz + off) && (sz <= sz + off) || (0 == sz + off))
  && (sz + off <= allocSize)

it now produces
  (sz <= allocSize) && (off <= allocSize - sz)

Fixes GaloisInc/saw-script#587.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant