[klee-dev] Question about how Klee performs symbolic execution

Rutledge, Richard L rrutledge at gatech.edu
Thu Nov 10 01:10:04 GMT 2016


I hope someone can clarify up a little klee-fundlement on my part regarding how Klee performs symbolic execution. Consider the following example program:

--------------------------------------------------------
#include <klee/klee.h>

#define MAXSTR 10

int test(char *str, int offset) {

  if (str[offset] == '\n') {
    return 1;
  }
  return 0;
}

int main(int argc, char *argv[]) {

  char str[MAXSTR];
  int offset;

  klee_make_symbolic(str, MAXSTR, "str");
  offset = klee_int("offset");
  klee_assume(offset >= 0);
  klee_assume(offset < MAXSTR);

  int result = test(str, offset);

  return result;
}
--------------------------------------------------------

There are two paths through this program. As expected, Klee finds exactly two paths and generates two test cases.

However, if I delete to two klee_assume() statements, then Klee finds 186 paths/test cases.
 
What leads to the path explosion? Without the assumes, the program admits undefined behavior, but does not introduce any new paths. It still only has two and execution should fork into two states at the test() if statement. What condition forks the other 184 states?

Cheers and Thanks!
Rick Rutledge






More information about the klee-dev mailing list