Lazy TLS initialization vs. TCMalloc.

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Mar 22 20:18:00 GMT 2016


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



More information about the Libc-alpha mailing list