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

Virtual functions execution in symbolic object #330

Closed
S1eGa opened this issue Jul 19, 2022 · 4 comments
Closed

Virtual functions execution in symbolic object #330

S1eGa opened this issue Jul 19, 2022 · 4 comments
Assignees
Labels
bug Something isn't working klee Related to internal work of KLEE

Comments

@S1eGa
Copy link
Collaborator

S1eGa commented Jul 19, 2022

KLEE issue. Whenever object of class with virtual functions is made symbolic, we are generating many tests cases and waiting for forever in the end.

Consider the following test case:

#include <cassert>
#include "klee/klee.h"

struct A {
  int x = 10;
  virtual void foo() {
    x += 1;
  }
};

struct B : A {
  virtual void foo() {
    x += 2;
  }
};

int main() {
  A *a = new B();
  klee_make_symbolic(a, sizeof(B), "a");
  a->x = 100;
  a->foo();
  assert(a->x == 101); 
}

We are expect to generate 1 test, that will fail assert.

Instead we are getting weird test cases, as shown below, and non of them fails the assertion, and KLEE does not stop the execution.

KLEE: Using STP solver backend
KLEE: WARNING ONCE: Alignment of memory from call "_Znwm" is not modelled. Using alignment of 8.
KLEE: ERROR: exmple.cpp:21: memory error: out of bound pointer
KLEE: NOTE: now ignoring this error at this location
KLEE: ERROR: exmple.cpp:21: invalid function pointer
KLEE: NOTE: now ignoring this error at this location

Compiled and executed with:

clang -emit-llvm -c -g -O0 -Xclang -disable-O0-optnone example.cpp
klee example.bc
@S1eGa S1eGa added the bug Something isn't working label Jul 19, 2022
@ladisgin ladisgin added the klee Related to internal work of KLEE label Jul 20, 2022
@ladisgin
Copy link
Member

@getn1ght, add klee run command and example without io

@S1eGa
Copy link
Collaborator Author

S1eGa commented Jul 20, 2022

@getn1ght, add klee run command and example without io

Updated.

@S1eGa
Copy link
Collaborator Author

S1eGa commented Jul 20, 2022

The problem is likely in klee_make_symbolic: a pointer to virtual functions table stored in class instance, and we will clear it, if make object symbolic; e.g., this problem does not seems to appear if we have only base class.

@ladisgin
Copy link
Member

ladisgin commented Mar 9, 2023

moved to UnitTestBot/klee#63

@ladisgin ladisgin closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working klee Related to internal work of KLEE
Projects
Status: Done
Development

No branches or pull requests

2 participants