public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: rajpal gusain <rajpal.gusain@gmail.com>
To: libc-help@sourceware.org
Subject: Help regarding bug 25533 (RTLD_DEEPBIND, glibc, custom memory manager)
Date: Mon, 7 Mar 2022 14:07:21 -0800	[thread overview]
Message-ID: <132AB50E-6AB1-4B5E-A87A-3D5DC680271E@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

Hi all,
I need help regarding an issue for which I created bug 25533 a while ago.

The issue is mainly because of complex interaction of RTLD_DEEPBIND, libc and custom memory manager. 
Let me explain issue first
1. In my application, I use a third party application which makes use of dlopen with RTLD_DEEPBIND flag
2. In my application, this third party application is linked statically along with Google’s memory manager (gperftools <https://github.com/gperftools/gperftools>).
3. When third party application calls dlopen with RTLD_DEEPBIND flag, strdup (along with malloc) gets picked from glibc. 
4. free definition is still communing from custom memory manager and it’s a problem as malloc’ed memory was allocated by libc malloc while free call is directed to custom memory manager.

I asked third party application vendor to fix it at their end (dlopen with RTLD_DEEPBIND), but they expressed their inability to do it as it has side effect.
I filed ticket against tcmalloc as well but it also hit dead end. As a workaround, I made use of malloc hooks.

But, I consider malloc hooks as temporary workaround and I’m looking for proper solution to this problem and IMO, proper fix should be in glibc which should be agnostic to memory manager 
that any application chooses. I believe jemalloc (Facebook) also has same issue and they also have used malloc hooks to work around this problem. 
Through this email, I’m looking for suggestions to fix this issue properly. 

I have created a small test case which is not exactly what is there in my application but closely resembles what I see. It’s dependent on TCMALLOC_STATIC_LIB variable which should be path to static library (.a) for custom memory manager.



Thanks
Rajpal Singh

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1394 bytes --]

                 reply	other threads:[~2022-03-07 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=132AB50E-6AB1-4B5E-A87A-3D5DC680271E@gmail.com \
    --to=rajpal.gusain@gmail.com \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).