public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "Soni L." <fakedme+libc@gmail.com>, Libc-help <libc-help@sourceware.org>
Subject: Re: The case for statically linked libc/pthread
Date: Tue, 15 Mar 2022 09:07:01 -0300	[thread overview]
Message-ID: <07c60a94-76b5-4db3-3832-c1ad5aff0487@linaro.org> (raw)
In-Reply-To: <5e390a65-bcfc-5924-cd49-39222d640165@gmail.com>



On 27/02/2022 16:57, Soni L. via Libc-help wrote:
> It'd be nice if the kernel could keep track of which code segments
> allocated memory or spawned threads, so that dlclose can release those
> resources. In fact this is particularly important for correctness in
> dlclose. But that requires libc to be statically linked in the first place.
> 
> There's no hope for dlclose without statically linked libc.

Although deprecated, glibc still supports dlopen for static binaries so it
won't help you much.  AFAIU the idea is eventually make no-op on static
build.

For dynamic linker binaries, a kernel interface would probably introduce a
large slow down on munmap (another interface to check if pointer is used
might introduce ABA issues): kernel will need to stop the process and
check N mmap against M threads (so the naive implementation will be O(n*m),
maybe with some clever data structure it could be lowered). So I think it
high unlikely that kernel will ever provide such interface, no for POSIX
like kernel like Linux.

Another option would be to make dlclose always a nop, for static and
dynamic, as musl does. However some users do expect that dlclose unmap the
memory segments and the library is reinitialized (run constructors, init
functions, etc) [1] [2].

In any case I think it is a fair assumption with current API that 
synchronization should be done by the program.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=16805
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=28877

      reply	other threads:[~2022-03-15 12:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-27 19:57 Soni L.
2022-03-15 12:07 ` Adhemerval Zanella [this message]

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=07c60a94-76b5-4db3-3832-c1ad5aff0487@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fakedme+libc@gmail.com \
    --cc=libc-help@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).