Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KLEE for C++ code that uses pthreads

Tags:

llvm

klee

I am a beginner trying to use KLEE. I am using the KLEE self contained package to on a C++ program that uses pthreads. I have generated a .o file and used KLEE with the following option

klee --libc=uclibc --posix-runtime test.o

But i see i get warning

KLEE: NOTE: Using model:
/home/pgbovine/klee/Release+Asserts/lib/libkleeRuntimePOSIX.bca

KLEE: output directory = "klee-out-4"
KLEE: WARNING: undefined reference to function: klee_get_valuel
KLEE: WARNING: undefined reference to function: pthread_create
KLEE: WARNING: undefined reference to function: pthread_exit
KLEE: WARNING: undefined reference to function: pthread_join
KLEE: WARNING: executable has module level assembly (ignoring)
KLEE: WARNING: calling external: syscall(54, 0, 21505, 571522624)
KLEE: WARNING: calling __user_main with extra arguments.
KLEE: WARNING: calling external: pthread_create(571589384, 0, 563903904, 571574176)
0  klee 0x08965ab8
[pid  1846] +++ killed by SIGSEGV +++

+++ killed by SIGSEGV +++
Segmentation fault

Using klee on a .bc file also gives me the same result.

I am not sure why i get undefined reference to pthread functions. I am not sure if the libraries for pthreads are being used properly. Is there a way to ensure this? Using the llvm-ld also does not help.

Below is the llvm-ld command that i used

 llvm-ld tests.bc -l=/usr/lib/libpthread.a

I am not sure why there Segmentation fault occurs. The program works fine when i normally compile the programs with g++ and run the executable file.

Could someone tell me where i am going wrong?

like image 380
Dimurali Avatar asked Dec 19 '25 23:12

Dimurali


1 Answers

The issue is that there is no existing pthread support in Klee. Hence, when you call pthread_create(), the Klee will not respond to it(that's why you see KLEE: WARNING: calling external: pthread_create). In this case, Klee will crash due to this failure.

like image 152
byteocean Avatar answered Dec 24 '25 11:12

byteocean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!