mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] building statically linked DSOs with musl
Date: Sun, 2 Jan 2022 22:41:05 +0100	[thread overview]
Message-ID: <20220102214105.GA2629@voyager> (raw)
In-Reply-To: <54060b8f-2ff1-fa1c-abc7-ac4996858ffb@m-labs.hk>

On Sat, Jan 01, 2022 at 10:31:58PM +0800, Sebastien Bourdeauducq wrote:
> On 1/1/22 21:58, Alex Xu (Hello71) wrote:
> > First,
> > malloc implementations (may) use a process-global resource: (s)brk. It
> > will cause havoc if multiple implementations attempt to simultaneously
> > manipulate it. Second, even if no more than one implementation uses
> > (s)brk, they will still have incompatible metadata.
>
> Can't there be two different heaps in different memory regions?
>

There can be different heaps, but not different brk heaps. Basically,
brk() manages a global variable generated by the kernel. You can work
around that problem by installing a seccomp filter that makes brk()
always fail, forcing the allocators to fall back to mmap().

However, your approach has numerous other problems, especially with the
mismatch between glibc and musl. The thread pointer does not match up,
and so no functions accessing the thread pointers will work. That
includes functions that read the current thread pointer, so you cannot
know in advance which those are. All the implementation-defined
structures mismatch, so none of the locking functions work, and neither
do the semaphore functions. The thread-management functions also will
not work, and you are saying you have complex dependencies that might
use those.

No, the best you can probably do is put all the work into a separate
program. Define some sort of IPC interface, and have the plugin merely
serialize requests and read responses. Then your process can be as
complicated as you want and use whatever libc you fancy. It can even use
a custom malloc. And your plugin should be rather lean.

HTH,
Markus

  reply	other threads:[~2022-01-02 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01  9:32 Sebastien Bourdeauducq
2022-01-01 12:56 ` Joakim Sindholt
2022-01-01 13:58   ` Alex Xu (Hello71)
2022-01-01 14:31     ` Sebastien Bourdeauducq
2022-01-02 21:41       ` Markus Wichmann [this message]
2022-01-03  1:37   ` Sebastien Bourdeauducq
2022-01-03  7:05     ` Markus Wichmann

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=20220102214105.GA2629@voyager \
    --to=nullplan@gmx.net \
    --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).