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

LeakSanitizer: interaction with __attribute__((__destructor__)) #1796

Open
oerdnj opened this issue Sep 10, 2024 · 0 comments
Open

LeakSanitizer: interaction with __attribute__((__destructor__)) #1796

oerdnj opened this issue Sep 10, 2024 · 0 comments

Comments

@oerdnj
Copy link

oerdnj commented Sep 10, 2024

Hi,

in a fairly complicated program (BIND 9) with internal libraries that use __attribute__((__constructor__)) and __attribute__((__destructor__)), we have LeakSanitizer report leaked memory from the main thread before the .fini section of the libraried are finished.

This gets even more complicated by fact that BIND 9 is using Userspace RCU library that also uses .init and .fini sections.

All of the constructors and destructors have default priorities.

Now, this gets even more complicated - RCU has an API that moves some free()-like calls to a dedicated thread (because this is how you do memory-reclamation in Userspace-RCU) and those objects are reported as lost unless you call rcu_barrier() before the program exits.

There is a call in the library destructor, but the destructor is apparently called after the LeakSanitizer is triggered and reports the leaked memory.

Now, the question (issue? bug report?) is - how to ensure that the LeakSanitizer runs after all other atexit()-like code is executed? Is there even a way to do that? It would be possible for me to execute some internal call from our own destructor, but is there a way to not execute the default one?

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