Description
For the following snippet of code:
int main() {
int *a = malloc(10 * sizeof(int));
int c = a[100000];
free(a);
return 0;
}
When compiled with clang -O0 file.c
, it generates an executable that causes the segmentation fault. However, if I verify its memory safety property with SMACK, I got no error trace.
The reason is that in the smacked version, the c
variable in the final LLVM bitcode is dead, and its entire assignment statement is optimized away. While in the non-optimized code, the statement exists. This could bring about fatal security issues because the verified version is not the version that is finally executed.
Is there a way in the SMACK toolchain to solve the problem? Or does the toolchain provide the guarantee that the verified version is semantically identical to the -O2
, or some level of an optimized version of clang
?