SimpleProgramAnalyser / spa

A CMake Windows program for a SIMPLE language
GNU General Public License v3.0
3 stars 0 forks source link

Potential AffectsBip Traversal Bug #163

Closed Dandford closed 4 years ago

Dandford commented 4 years ago

image image Query returns: stmt s1, s2, s3, s4; variable v; constant c; Select such that AffectsBip(s1,42) Expected Answer: 39, 60 Actual Answer: 39, 60, 64, 75

Procedures proc2NestingIfWhile and proc2NestingWhileIf aren't called anywhere else in the program

Dandford commented 4 years ago

multipleAffectsBipPatternWithSource.txt

alcen commented 4 years ago

Seems like source of this bug is because NextBip table is used for one known synonym, but there is no way to tell between different calls with the NextBip table

This is a small test program that demonstrates the bug:

procedure a {
    a = a;
    call called;
    b = b;
}

procedure b {
    b = b;
    call called;
    a = a;
}

procedure called {
    if (a < b) then {
        a = a + b;
    } else {
        b = a + b;
    }
}

image

Fix would be to run the affectsSearch every time. This can be forced in the current version by adding a placeholder clause to populate the cache:

image