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

__cxa_finalize makes it hard to implement opposite __cxa_atexit order #146

Open
fweimer-rh opened this issue Aug 23, 2022 · 0 comments
Open

Comments

@fweimer-rh
Copy link

The specification is pretty clear that __cxa_finalize should be called via the ELF destructor mechanism and invoke the registered __cxa_atexit callbacks for that particular shared object. But the ELF destructor order is not necessarily sequenced in a compatible way with the opposite __cxa_atexit order. This results in the wrong sequence of C++ destructor calls.

This specification seems to date back to an era where C++ implementations without a way to integrate with the system dynamic linker were common. Nowadays, I think we can do better by teaching the dynamic linker to invoke __cxa_atexit callbacks in the exact opposite order (regardless of DSOs), and do nothing in __cxa_finalize. But the current specification seems to preclude such a standards-conforming implementation, by explicitly tying the callbacks to the ELF destructor invocation.

(@jwakely brought this up recently.)

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