ckaestne / TypeChef

Type checking ifdef variability
https://ckaestne.github.io/TypeChef/
Other
76 stars 36 forks source link

CFG construction introduces wrong feature annotations on functions #37

Closed clhunsen closed 9 years ago

clhunsen commented 9 years ago

In joint work with Stefan from Vienna and Thomas (@bockthom), we discovered that there is a bug in the --dumpcfg routine of TypeChef.

Consider following input file with an empty feature model:

void bar() {
}
void foo() {
#ifdef X
    bar();
#endif
}

As a sidenote, TypeChef (on 083e742aa3ce2f5a1d333dd84143c41c57dde8e3, most recent commit on master) is called like this:

./typechef.sh /tmp/testsystem/foo4.c -o /tmp/testsystem/foo4.c --bdd --featureModelFExpr /tmp/testsystem/fm.txt --dumpcfg --lexNoStdout

From the example file, it is clear that the node for the function declaration of foo in the resulting control-flow graph is NOT annotated with a feature. Nevertheless, there is a feature annotation in the resulting graph: foo4 c cfg dot

N;21;function;2;bar;1
E;21;21;1
E;21;21;1
N;42;statement;9;bar()::foo;definedEx(X)
E;42;21;definedEx(X)
N;63;function;7;foo;definedEx(X)
E;42;63;1
E;63;42;definedEx(X)
E;63;63;1

As you can see on the bold line, the function foo is annotated with definedEx(X) – instead of 1. The other nodes and all the edges are fine, however.


I guess, the error results from a non-flushed temporary data structure. At least, it sounds like something of this kind. Hopefully, someone, who is familiar with the code, can help on this problem.

Thanks in advance.

joliebig commented 9 years ago

No, the error is caused by a bug in the dot-writer implementation. The annotation of the Stmt 8: bar() was used when writing node Function 6: foo.

The edge Function 6: foo -> Function 6: foo is wrong, too. It should be ! defined(x). Fixed this one also.

clhunsen commented 9 years ago

Thanks for the fixes. I ran a test with the file, here the results:

foo4 c cfg dot

N;21;function;1;bar;1
E;21;21;1
E;21;21;1
N;42;statement;8;bar()::foo;definedEx(X)
E;42;21;definedEx(X)
N;63;function;6;foo;1
E;42;63;definedEx(X)
E;63;42;definedEx(X)
E;63;63;!definedEx(X)

The bold parts have changed. Looks good to me now.