Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple klee_make_symbolic on the same object #248

Closed
paulmar opened this issue Jun 25, 2015 · 1 comment · Fixed by #379
Closed

Handle multiple klee_make_symbolic on the same object #248

paulmar opened this issue Jun 25, 2015 · 1 comment · Fixed by #379
Labels

Comments

@paulmar
Copy link
Contributor

paulmar commented Jun 25, 2015

Reported by Alexander Kampmann on the mailing list

The output of the ktest-tool is:

ktest file : 'klee-out-5/test000004.ktest'
args : ['main.bc']
num objects: 3
object 0: name: 'model_version'
object 0: size: 4
object 0: data: '\x01\x00\x00\x00'
object 1: name: 'var2'
object 1: size: 6
object 1: data: '\x00\x00\x00\x00\x00\x00'
object 2: name: 'var2'
object 2: size: 6
object 2: data: '\x01\x01\x01\x00\x00\x00'

As you can see, there are two objects named 'var2' and no object named
'var1'. The c code is:

#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv) {
       char *var1 = "Hallo";
       char *var2 = "Hallo";
       klee_make_symbolic(var1, 6*sizeof(char), "var1");
       klee_assume(var1[5] == 0);
       klee_make_symbolic(var2, 6*sizeof(char), "var2");
       klee_assume(var2[5] == 0);

       for(int i=0;i<strlen(var1);i++) {
               if(var1[i] != var2[i]) {
                       return 1;
               }
       }
       return 0;
}

It has 'var1' and 'var2', and makes both of them symbolic. The loop is
merely to give klee some branches to work with. 'var1' is missing in the
ktest-tool output. I am compiling with

clang -c -g -emit-llvm main.c

and running klee with

klee --libc=uclibc --posix-runtime -max-time=30 main.bc

@andreamattavelli
Copy link
Contributor

I ran in the same problem in an off-line discussion by helping running KLEE on a similar example.
It seems like that KLEE gets confused by the fact that var1 and var2 are aliases of the same memory address ("Hallo" is compiled by clang to a global variable @str). In fact, by changing one of the two strings everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants