From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Cc: Zibin Liu <ghostfly23333@gmail.com>
Subject: Re: [musl] ptc in pthread
Date: Fri, 16 Aug 2024 16:38:39 +0200 [thread overview]
Message-ID: <Zr9kb0Rbm4smDV2q@voyager> (raw)
In-Reply-To: <CABKykw=G8=DwnS1sXw0pzB-TT49Z_v9LqVACGoFFh8VZveMkew@mail.gmail.com>
Am Fri, Aug 16, 2024 at 10:51:53AM +0800 schrieb Zibin Liu:
> Despite this, I’m still unclear on why dlopen needs to ensure that the
> thread count does not increase. Could someone provide more details on
> this?
This is in case a library is opened that contains TLS. In that case, the
thread calling dlopen() must allocate a new TLS block for the library
for every thread that currently exists, as well as a new DTV to contain
the pointers. If a thread could be created during this, obviously there
could be a thread created without that TLS block.
musl doesn't use the lazy TLS initialization scheme glibc uses, because
that one admits no failure. In that scheme, memory for the new TLS is
allocated in __tls_get_addr(), but if allocation fails, there is no
choice but to abort. In musl's implementation, the memory is allocated
in dlopen(), and if it cannot be allocated, the dlopen() fails.
The lock cannot be reduced in scope to the TLS installation, since each
library can pull in dependencies that can also have TLS.
Ciao,
Markus
next prev parent reply other threads:[~2024-08-16 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 2:51 Zibin Liu
2024-08-16 14:38 ` Markus Wichmann [this message]
2024-08-16 15:51 ` Rich Felker
2024-08-16 15:40 ` Rich Felker
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=Zr9kb0Rbm4smDV2q@voyager \
--to=nullplan@gmx.net \
--cc=ghostfly23333@gmail.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).