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

Stub definition of __cxa_thread_atexit_impl #1290

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

alastairreid
Copy link
Contributor

This function is usually a weak symbol but, in KLEE, this behaves like a call
to an unknown function and chaos ensues.
Worse, it happens just as the program is cleanly shutting itself down,
so programs that are cleanly exiting crash with the wrong message.

@ccadar
Copy link
Contributor

ccadar commented Jul 31, 2020

Thanks, @alastairreid . Do you have a small test case for this?
And just wondering, shouldn't this function be defined in libcxx?

@alastairreid
Copy link
Contributor Author

oops, forgot to add a testcase - will add that and push another update.

Good question about where to put it - I had not thought much about it.
I think that adding it to the existing runtime/klee-libc/__cxa_atexit.c might be the right place.

@ccadar
Copy link
Contributor

ccadar commented Aug 14, 2020

Thanks again, @alastairreid , let's add this. But can you move the test to a new test/Runtime/KLEE-Libc directory? (as it's unrelated to uclibc).

@ccadar
Copy link
Contributor

ccadar commented Aug 21, 2020

Thanks, @alastairreid and sorry for one more request, but can you rebase this into a single commit?

This is a thread-local version of __cxa_atexit (but, in the absence
of threads, it is sufficient to just call __cxa_atexit).

The test is based on the existing test for atexit in
test/Runtime/Uclibc/2008-03-04-libc-atexit-uses-dso-handle.c

The motivation for adding this function is to support the Rust standard
library that calls __cxa_thread_atexit_impl.
This function is usually a weak symbol but, in KLEE, this behaves like a call
to an unknown function and chaos ensues.
Worse, it happens just as the program is cleanly shutting itself down,
so programs that are cleanly exiting crash with the wrong message.
@alastairreid
Copy link
Contributor Author

Rebased and squashed.
(I'm still trying to get used to the way github-based code review works. Rebasing and squashing fits my preferred style better.)

Copy link
Contributor

@MartinNowack MartinNowack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alastairreid Excellent! Thanks for this PR. Going to merge.

@MartinNowack MartinNowack merged commit a04538a into klee:master Aug 28, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants