-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
dlopen with RTLD_DEEPBIND causes crash #1148
Comments
Now, when I know this issue, it looks like others have also faced it with other memory manager (jemalloc) and it seems like jemalloc has fix for it (I verified it on small test and it works and works as I suggested earlier) |
Thanks for report. Notably that mozilla ticket is 11 years old. Also glibc has deprecated those hooks long time ago. So gperftools dropped usage of those hooks in this commit: 7822b5b So I am not sure how to help you, maybe don't use RTLD_DEEPBIND ? |
Thanks for your comment.
What you see is a small hand-crafted test case after debugging crash which involves third party licensing library code which obfuscates debugging symbols. And this RTLD_DEEPBIND comes from inside third party code. |
I understand. Thing is, glibc folks promised they'll soon shoot glibc's hooks. |
Any suggestions how to make progress on this issue ? |
There are two solutions:
These are advanced topics for application design, and you cannot assume that you can freely change allocators like this or use RTLD_DEEPBIND without carefully architecting the application. While glibc makes it possible to replace the system allocator it doesn't mean that this will work in all conceivable scenarios without additional design work. Likewise dlmopen can cause similar problems with namespaces leaking pointers from different allocators. |
Can you please explain it ? Please note that I intend to use tcmalloc as the "malloc" for entire application but there is a third party software which calls dlopen with RTLD_DEEPBIND and calls glibc pt malloc. It's clear that even tcmalloc would have worked fine but just because of DEEPBIND it gets malloc from glibc.
My earlier comment applies to this point as well; I don't want to switch memory managers but I need some way to force it. I can't change third party software. |
test.tar.gz
After spending good amount of time on a crash which originates from third party software which is complete blackbox, I finally understand what went wrong and I have created a tiny test case for it.
Steps to reproduce:
% untar
% make all TCMALLOC_STATIC_LIB=
% a.out
And it crashes like this
Reason for crash is that malloc/free definition from shared library libtest.so comes from libc.so while malloc definition from shared library libc.so (for strdup) comes from tcmalloc, and when libc free tries to free tc alloced block, it crashes.
In my opinion, all malloc/free should have come from tcmalloc and there would have been no problem whatsoever.
The text was updated successfully, but these errors were encountered: