|
From: Jeremy F. <je...@go...> - 2004-02-29 23:39:55
|
On Sun, 2004-02-29 at 14:16, Tom Hughes wrote:
> In message <1078091257.30493.82.camel@localhost.localdomain>
> Jeremy Fitzhardinge <je...@go...> wrote:
>
> > my_malloc ends up calling real malloc(), which on some libc's ends up
> > calling init_libc_tsd_keys recursively. The mutex is already held, so
> > it fails the second time through.
>
> Doesn't init_libc_tsd_keys already check for recursive calls before
> trying to do the lock though?
Not correctly. The recursion path is:
init_libc_tsd_keys ->
__pthread_key_create ->
get_or_allocate_specifics_ptr ->
my_malloc ->
malloc ->
... ->
init_libc_tsd_keys
init_libc_tsd_keys doesn't set libc_specifics_inited until after calling
__pthread_key_create.
Perhaps it should set it as early as possible.
J
|