mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Érico Nogueira" <ericonr@disroot.org>
To: <musl@lists.openwall.com>, <musl@lists.openwall.com>
Subject: Re: [musl] [PATCH v2] MT fork
Date: Mon, 09 Nov 2020 15:54:55 -0300	[thread overview]
Message-ID: <C6YYM8AR0YV8.2PU2J2QLOSU1T@mussels> (raw)
In-Reply-To: <20201109184456.GB534@brightrain.aerifal.cx>

On Mon Nov 9, 2020 at 10:44 AM -03, Rich Felker wrote:
> On Mon, Nov 09, 2020 at 03:01:24PM -0300, Érico Nogueira wrote:
> > On Mon Nov 9, 2020 at 9:07 AM -03, Rich Felker wrote:
> > > One solution you might actually like: getting rid of
> > > application-provided-malloc use inside libc. This could be achieved by
> > > making malloc a thin wrapper for __libc_malloc or whatever, which
> > > could be called by everything in libc that doesn't actually have a
> > > contract to return "as-if-by-malloc" memory. Only a few functions like
> > > getdelim would be left still calling malloc.
> > 
> > This code block in glob() uses strdup(), which I'd assume would have to
> > use the application provided malloc. Wouldn't that have to be worked
> > around somehow?
> > 
> > 	if (*pat) {
> > 		char *p = strdup(pat);
> > 		if (!p) return GLOB_NOSPACE;
> > 		buf[0] = 0;
> > 		size_t pos = 0;
> > 		char *s = p;
> > 		if ((flags & (GLOB_TILDE | GLOB_TILDE_CHECK)) && *p == '~')
> > 			error = expand_tilde(&s, buf, &pos);
> > 		if (!error)
> > 			error = do_glob(buf, pos, 0, s, flags, errfunc, &tail);
> > 		free(p);
> > 	}
>
> It could either be left using public malloc (imo fine since this is
> not an "internal component of libc" but generic library code with no
> tie-in to libc) or use of strdup could be replaced with a trivial
> alternate version that uses __libc_malloc instead. My leaning would be
> towards the former -- only using libc malloc in places where calling
> the application-provided malloc could lead to recursive locking of
> libc-internal locks (because the caller already holds a libc-internal
> lock) or other "inconsistent state" issues (like dlerror buffers at
> pthread_exit time).

Ok, I think I hadn't understood the problem space completely. Given this
explanation, I would agree that allowing this to use an appliccation
provided malloc is fine, and might even be desirable, since it would
perform as many allocations as possible with the provided allocator.

That said, could this somehow hurt malloc tracking inside libc, be it
with valgrind or sanitizers?

  reply	other threads:[~2020-11-09 19:43 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26  0:50 [musl] Status report and " Rich Felker
2020-10-26  0:59 ` Rich Felker
2020-10-26  3:29   ` Rich Felker
2020-10-26 18:44     ` Érico Nogueira
2020-10-26 19:52       ` Rich Felker
2020-10-26 20:11         ` Érico Nogueira
2020-10-27 21:17   ` Rich Felker
2020-10-28 18:56     ` [musl] [PATCH v2] " Rich Felker
2020-10-28 23:06       ` Milan P. Stanić
2020-10-29 16:13         ` Szabolcs Nagy
2020-10-29 16:20           ` Rich Felker
2020-10-29 20:55           ` Milan P. Stanić
2020-10-29 22:21             ` Szabolcs Nagy
2020-10-29 23:00               ` Milan P. Stanić
2020-10-29 23:27                 ` Rich Felker
2020-10-30  0:13                   ` Rich Felker
2020-10-30  7:47                   ` Milan P. Stanić
2020-10-30 18:52                     ` Milan P. Stanić
2020-10-30 18:57                       ` Rich Felker
2020-10-30 21:31                         ` Ariadne Conill
2020-10-31  3:31                           ` Rich Felker
2020-11-06  3:36                             ` Rich Felker
2020-11-08 16:12                               ` Szabolcs Nagy
2020-11-09 17:07                                 ` Rich Felker
2020-11-09 18:01                                   ` Érico Nogueira
2020-11-09 18:44                                     ` Rich Felker
2020-11-09 18:54                                       ` Érico Nogueira [this message]
2020-11-09 21:59                                   ` Szabolcs Nagy
2020-11-09 22:23                                     ` Rich Felker
2020-11-11  0:52                                       ` Rich Felker
2020-11-11  6:35                                         ` Alexey Izbyshev
2020-11-11 11:25                                           ` Szabolcs Nagy
2020-11-11 14:56                                             ` Rich Felker
2020-11-11 16:35                                         ` Rich Felker
2020-10-31  7:22                           ` Timo Teras
2020-10-31 13:29                             ` Szabolcs Nagy
2020-10-31 13:35                               ` Timo Teras
2020-10-31 14:41                                 ` Ariadne Conill
2020-10-31 14:49                                   ` Rich Felker
2020-10-31 14:48                                 ` Rich Felker
2020-10-31 14:47                             ` Rich Felker
2020-10-29 23:32                 ` Szabolcs Nagy

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=C6YYM8AR0YV8.2PU2J2QLOSU1T@mussels \
    --to=ericonr@disroot.org \
    --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).