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

Atexit handler not called after exit(2) using klee-libc #1719

Open
fwc opened this issue Apr 17, 2024 · 0 comments
Open

Atexit handler not called after exit(2) using klee-libc #1719

fwc opened this issue Apr 17, 2024 · 0 comments

Comments

@fwc
Copy link
Contributor

fwc commented Apr 17, 2024

The atexit imlementation of the KLEE-libc does not work, when exit is called "explicitely".
Note that at an explicit exit call, the functions registered with atexit ought to be called.

So, the following CHECK does fail when running with the KLEE libc (but it works fine with uclibc).
fwc@aebd8f83 shows the complete test.

void foo() { printf("called foo\n"); }
int main() {
  atexit(foo);
  exit(0);
  // CHECK: called foo          <-- fails
}

The bug occurs since the functions registered via atexit are called by RunAtExit which is marked with __attribute__((destructur)). The destructor is called after exiting main. The "explicit" exit-call is handled by the SpecialFunctionHandler, which directly terminates the state, which thus does not exit main, thus not calling the destructor.

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

No branches or pull requests

1 participant