GillianPlatform / Gillian

The Gillian Platform main repository
https://GillianPlatform.github.io
BSD 3-Clause "New" or "Revised" License
73 stars 11 forks source link

Ensure fixes are not lost when they lead to errors #302

Closed N1ark closed 1 month ago

N1ark commented 2 months ago

If a bug is found in bi-abduction that happens during the same command a fix is generated, the state before the command was executed is used to generate the spec, which means the fix gets lost. This PR modifies BiState to always include an up to date copy of the state along with every memory error. When encountering failures, Abductor then checks if any of the errors is a memory error, in which case it uses the attached state rather instead.

Example

For a state model stack Freeable(Exclusive):

bispec test () : [[ emp  ]]
proc test() {
    gvar0 := [load]();
    ret := 0i;
    return
};

Generated specs diff (before/after):

BUG SPECS:
  spec test ()
    ;
-   [[ emp ]]
-   [[ emp ]]
+   [[ <freed>(; ) ]]
+   [[ <freed>(; ) ]]
    bug

ERROR SPECS:

SUCCESSFUL SPECS:
  spec test ()
    [[ <points_to>(; #gen__0) ]]
    [[ (ret == 0i) * <points_to>(; 6i) ]]
    normal;

Notes

A couple hacky things I did, that I don't like but don't know how to avoid (I'm happy to edit the PR with suggestions):