简体   繁体   中英

Why the function sleep() can not work when the klee execute the Objectfile?

Yesterday I asked question on stackoverflow, but I have not described it clearly, so I change the way to ask, maybe make the problem clear. First, I modify the example get_sign.c which the klee provide, I include the unistd.h in the program, and call the function sleep() to make the thread pause, as follows

/*
 * First KLEE tutorial: testing a small function
 */
#include <unistd.h>

int get_sign(int x) {
  if (x == 0)
     return 0;

  if (x < 0)
     return -1;
  else 
     return 1;
} 

int main() {
  int a;
  klee_make_symbolic(&a, sizeof(a), "a");
  sleep(10);
  return get_sign(a);
} 

I use the " llvm-gcc " compile the get_sign.c, then use klee get_sign.o to execute the objectfile, the thread do not pause, means the sleep() does not work. so I add a argument when I execute the get_sign.o, like this klee --libc=uclibc get_sign.o , unfortunately, the thread still don't suspend, moreover, the klee reports a error,

KLEE: ERROR: /home/lab/work/klee-uclibc/libc/signal/sigaction.c:58: failed external call: __syscall_rt_sigaction

KLEE: NOTE: now ignoring this error at this location

What can I do to solve this problem? thank you!

Looks like klee uses signals which can make sleep return sooner than expected, as indicated in http://www.delorie.com/gnu/docs/glibc/libc_445.html . This reference also provides ways to go around the limitation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM