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

Detect when jvm_return is missing when it was expected #938

Open
brianhuffman opened this issue Nov 25, 2020 · 2 comments
Open

Detect when jvm_return is missing when it was expected #938

brianhuffman opened this issue Nov 25, 2020 · 2 comments
Labels
subsystem: crucible-jvm Issues related to Java verification with crucible-jvm tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior
Milestone

Comments

@brianhuffman
Copy link
Contributor

PR #929 adds a collection of regression tests that ensure that crucible_jvm_unsafe_assume_spec and crucible_jvm_verify will catch ill-formed JVMSetup blocks. The tests for the type-correctness checks added in #929 work as expected. However there are a lot of other bogus JVMSetup blocks that are not caught; these are marked in the test script as "KNOWN FALSE POSITIVE".

We should enhance the well-formedness checks in SAW/JVM to eliminate all the known false positives in the test suite. These include:

@brianhuffman brianhuffman added the subsystem: crucible-jvm Issues related to Java verification with crucible-jvm label Nov 25, 2020
@brianhuffman brianhuffman self-assigned this Nov 26, 2020
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
Previously it represented the left-hand side with an arbitrary
`SetupValue`; however, the only valid `SetupValue`s for this purpose
are `SetupVar` applied to an `AllocIndex`. This change lets us
simplify code for the simulation phase, in exchange for doing more
error checking during the setup phase (which is also a good thing).

The early checking eliminates a couple of the known false positives
from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes one of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes more remaining known false positives of #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes more remaining known false positives of #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
Previously it represented the left-hand side with an arbitrary
`SetupValue`; however, the only valid `SetupValue`s for this purpose
are `SetupVar` applied to an `AllocIndex`. This change lets us
simplify code for the simulation phase, in exchange for doing more
error checking during the setup phase (which is also a good thing).

The early checking eliminates a couple of the known false positives
from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes one of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 3, 2020
This fixes more remaining known false positives of #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
Previously it represented the left-hand side with an arbitrary
`SetupValue`; however, the only valid `SetupValue`s for this purpose
are `SetupVar` applied to an `AllocIndex`. This change lets us
simplify code for the simulation phase, in exchange for doing more
error checking during the setup phase (which is also a good thing).

The early checking eliminates a couple of the known false positives
from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes one of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes more remaining known false positives of #938.
@brianhuffman
Copy link
Contributor Author

PR #948 fixes almost all of the remaining known false positive test cases.

One that remains is "jvm_return missing when one was expected", which will need to be fixed in a different way from most of the others: While all the other error checks are associated with running a specific setup command, this error condition can only be detected at a slightly later phase, by the surrounding function that actually runs the entire setup block and processes the resulting methodspec.

The other remaining test is "jvm_array_is with previous jvm_elem_is", where we have already specified the contents of one or more individual array elements, and then later we try to specify the contents of the whole thing. The problem here is in the definition of function testResolved, which is used to determine whether the location being specified has been specified already.

-- | Test whether the pointer represented by the given SetupValue has
-- been initialized already.
testResolved ::
SetupValue ext ->
[Either String Int] {-^ path within this object (if any) -} ->
ResolvedState ->
Bool
testResolved val0 path0 rs = go path0 val0
where
go path val =
case val of
SetupVar n -> test path (Map.lookup n (_rsAllocs rs))
SetupGlobal _ c -> test path (Map.lookup c (_rsGlobals rs))
SetupElem _ v idx -> go (Right idx : path) v
SetupField _ v fld -> go (Left fld : path) v
_ -> False
test _ Nothing = False
test path (Just paths) = any (`isPrefixOf` path) paths

That function is designed to only return True if the indicated location has been completely specified already; i.e. either the same location or else one that totally covers the current one is already in the map. But what we really want is a different check: We want to return False only if the indicated location is completely disjoint from all previously used locations; in the case of a partial overlap (like jvm_array_is after jvm_elem_is) we also want to get True. However, this change will need to be done with care, because this code is also used for LLVM specs and such a change could possibly break proof scripts. Probably the best approach is to make a PR that makes only this one small change.

brianhuffman pushed a commit that referenced this issue Dec 4, 2020
Previously it represented the left-hand side with an arbitrary
`SetupValue`; however, the only valid `SetupValue`s for this purpose
are `SetupVar` applied to an `AllocIndex`. This change lets us
simplify code for the simulation phase, in exchange for doing more
error checking during the setup phase (which is also a good thing).

The early checking eliminates a couple of the known false positives
from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes one of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes several more of the known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 4, 2020
This fixes more remaining known false positives of #938.
brianhuffman pushed a commit that referenced this issue Dec 8, 2020
Previously `testResolved` would detect a later points-to that pointed
entirely inside the region of an earlier points-to, but would not
detect an overlap if the points-tos were done in the opposite order.

This change makes the points-to comparison symmetric, so overlapping
points-to declarations are detected no matter what order they appear
in a spec.

This fixes one of the remaining known false positives from #938.
brianhuffman pushed a commit that referenced this issue Dec 9, 2020
Previously `testResolved` would detect a later points-to that pointed
entirely inside the region of an earlier points-to, but would not
detect an overlap if the points-tos were done in the opposite order.

This change makes the points-to comparison symmetric, so overlapping
points-to declarations are detected no matter what order they appear
in a spec.

This fixes one of the remaining known false positives from #938.
@atomb atomb added this to the 0.8 milestone Dec 11, 2020
brianhuffman pushed a commit that referenced this issue Jan 14, 2021
We now completely avoid using the `ResolvedState` code from
SAWScript.Crucible.Common, which is too specific to LLVM.

This fixes one of the remaining known false positives from
intTests/test_jvm_setup_errors (#938).
brianhuffman pushed a commit that referenced this issue Jan 22, 2021
Previously `testResolved` would detect a later points-to that pointed
entirely inside the region of an earlier points-to, but would not
detect an overlap if the points-tos were done in the opposite order.

This change makes the points-to comparison symmetric, so overlapping
points-to declarations are detected no matter what order they appear
in a spec.

This fixes one of the remaining known false positives from #938.
brianhuffman pushed a commit that referenced this issue Jan 26, 2021
We now completely avoid using the `ResolvedState` code from
SAWScript.Crucible.Common, which is too specific to LLVM.

This fixes one of the remaining known false positives from
intTests/test_jvm_setup_errors (#938).
brianhuffman pushed a commit that referenced this issue Jan 26, 2021
We now completely avoid using the `ResolvedState` code from
SAWScript.Crucible.Common, which is too specific to LLVM.

This fixes one of the remaining known false positives from
intTests/test_jvm_setup_errors (#938).
@atomb atomb modified the milestones: 0.8, 0.9 Apr 9, 2021
@atomb atomb removed this from the 0.9 milestone Sep 22, 2021
@brianhuffman
Copy link
Contributor Author

The issue with jvm_array_is and jvm_elem_is has been resolved; only the missing jvm_return case still remains.

@brianhuffman brianhuffman changed the title Fix all the known false positives in test_jvm_setup_errors regression test Detect when jvm_return is missing when it was expected Apr 28, 2022
@brianhuffman brianhuffman removed their assignment Apr 28, 2022
@sauclovian-g sauclovian-g added type: bug Issues reporting bugs or unexpected/unwanted behavior tech debt Issues that document or involve technical debt and removed method-spec labels Oct 24, 2024
@sauclovian-g sauclovian-g added this to the 2025T1 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: crucible-jvm Issues related to Java verification with crucible-jvm tech debt Issues that document or involve technical debt type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

4 participants