This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Lazy TLS initialization vs. TCMalloc.
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Tue, 22 Mar 2016 17:18:13 -0300
- Subject: Re: Lazy TLS initialization vs. TCMalloc.
- Authentication-results: sourceware.org; auth=none
- References: <56F1A3F8 dot 8080606 at redhat dot com>
On 22-03-2016 16:58, Carlos O'Donell wrote:
> I was asked to comment on Ceph/TCMalloc deadlock problems
> which appeared to be glibc-related. Given that I stood up
> and represented the community I'm posting what I wrote
> here for posterity:
>
> http://tracker.ceph.com/issues/13522#note-23
>
> The basic problem is that lazy TLS initialization has
> unknown requirements on the interposing malloc and TCMalloc
> gets it wrong.
>
> I hope that we can find somebody to fix the issue and that
> consensus remains that dlopen should allocate up front to
> avoid the issues with lazy initialization.
>
This is unfortunate, however TCMalloc recently implemented a sort
of emergency malloc [1] for the issue when backtrace may call
malloc itself. One solution could add wrapper on dlopen/dlclose
to use this emergency malloc, however I do see this an hack
solution.
Another one is to use initial-exec on all internal TLS variables
to avoid such traps. In fact I think this is the preferable one.
[1] https://github.com/gperftools/gperftools/commit/7f12051dbe1f402771a747c1192a66e7571d94f9