frama c - What does the message "unreachable entry point" mean? -
i have file containing several acsl assertions (file.c
):
#include <stdio.h> #include <stdlib.h> void foo() { int a=0; //@ assert(a==0); } void print(const char* text) { int a=0; //@ assert(a==0); printf("%s\n",text); } int main (int argc, const char* argv[]) { const char* a1 = argv[2]; print(a1); foo(); if (!a1) //@ assert(!a1); return 0; else return 1; }
i want slice assertions command:
frama-c -slice-assert @all file.c -then-on 'slicing export' -print -ocode slice.c
however, slice not expected (in fact not contain of functions contained in files):
/* generated frama-c */ typedef unsigned int size_t; /*@ ghost extern int __fc_heap_status __attribute__((__frama_c_model__)); */ /*@ axiomatic dynamic_allocation { predicate is_allocable{l}(size_t n) reads __fc_heap_status; } */ void main(void) { char const *a1; return; }
instead output this:
file.c:16:[kernel] warning: out of bounds read. assert \valid_read(argv+2); [value] recording results main [value] done function main file.c:16:[value] assertion 'value,mem_access' got final status invalid. [slicing] making slicing project 'slicing'... [slicing] interpreting slicing requests command line... [pdg] computing function foo [pdg] warning: unreachable entry point (sid:1, function foo) [pdg] bottom function foo [slicing] bottom pdg function 'foo': ignore selection [pdg] computing function main file.c:21:[pdg] warning: no final state. unreachable... [pdg] done function main [pdg] computing function print [pdg] warning: unreachable entry point (sid:5, function print) [pdg] bottom function print [slicing] bottom pdg function 'print': ignore selection
what going wrong here, in particular, unreachable entry point
? observation: if change argv[2]
argv[1]
don't have these problems (but still warning in first line).
the slicing needs compute pdg (program dependent graph) use value analysis results. warning unreachable entry point
means that, in context give, function foo
not reachable (ie. called unreachable statements).
difficult tell more without example...
edit:
in ouput provided, notice lines:
file.c:16:[kernel] warning: out of bounds read. assert \valid_read(argv+2);
and
file.c:16:[value] assertion 'value,mem_access' got final status invalid.
when value analysis meet invalid property, cannot go further. because here alarm comes first statement, else become unreachable. invalid property \valid_read(argv+2);
since default input context have width of 2 argv
. can fixed either using option -context-width 3
, or using entry point analysis (and specify -main my_main
) take no argument, define argc
, argv
explicitly, , call real main
them.
an advice use slicing after having checked if value analysis results ok. can run alone -val
option, , adjust other options if needed.
Comments
Post a Comment