[PATCH] malloc: Ensure that ptmalloc_init runs only once
Florian Weimer
fweimer@redhat.com
Thu Jun 17 14:31:14 GMT 2021
* Siddhesh Poyarekar via Libc-alpha:
> It is possible that multiple threads simultaneously enter
> ptmalloc_init and succeed the < 0 check. Make the comparison and
> setting of __malloc_initialized atomic so that only one of them goes
> through. Additionally, if a thread sees that another thread is
> running the initialization (i.e. __malloc_initialized == 0) then wait
> till it is done.
No, this cannot happen because pthread_create calls malloc before
creating the new thread.
Thanks,
Florian
More information about the Libc-alpha
mailing list