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 #63

Open
ladisgin opened this issue Mar 9, 2023 · 0 comments
Open

Virtual functions execution in symbolic object #63

ladisgin opened this issue Mar 9, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request с++

Comments

@ladisgin
Copy link
Member

ladisgin commented Mar 9, 2023

Moved from UnitTestBot/UTBotCpp#330

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request с++
Projects
None yet
Development

No branches or pull requests

2 participants