mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH v4] implement recallocarray(3)
Date: Sun, 2 Aug 2020 20:45:19 -0400	[thread overview]
Message-ID: <20200803004519.GZ6949@brightrain.aerifal.cx> (raw)
In-Reply-To: <20200802225426.32002-1-ariadne@dereferenced.org>

On Sun, Aug 02, 2020 at 04:54:26PM -0600, Ariadne Conill wrote:
> This OpenBSD extension is similar to reallocarray(3), but
> zero-initializes the new memory area.
> 
> This extension is placed in _BSD_SOURCE, like
> reallocarray(3).
> 
> Changes from v3:
> - use calloc() instead of realloc() and always copy
> - explicitly zero old memory block
> - restore overflow checking for old size
> 
> Changes from v2:
> - drop overflow checking for old size
> 
> Changes from v1:
> - use realloc() instead of reallocarray()

Can we finish discussion of questions raised before making new
versions with changes that haven't even been agreed upon? I asked
about EINVAL so we could determine if it's expected and if it's
reasonable to copy; that's not a demand to remove it. And the new
memset before free is a complete no-op. If there's a contract to
behave like explicit_bzero on the old memory, we may want to honor
that if we implement recallocarray, but that likely makes it entirely
unsuitable to the purpose you want it for and will bring back the
atrociously bad apk performance you previously saw with mallocng if
you use it there, since each increment of array size will incur a
whole memcpy of the existing array (quadratic time) rather than copies
only occuring a logarithmic number of times (yielding O(n log n)
overall) as would happen with realloc.

Overall I'm getting kinda skeptical of this function. Implementing it
without the hardness guarantees of the OpenBSD version seems like a
bad idea, but with those guarantees it just seems to be a bad
interface.

Rich

  reply	other threads:[~2020-08-03  0:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 22:54 Ariadne Conill
2020-08-03  0:45 ` Rich Felker [this message]
2020-08-03  1:35   ` Ariadne Conill
2020-08-03  1:58     ` Rich Felker
2020-08-03 15:11 ` Wolf
2020-08-03 15:15   ` Wolf
2020-08-03 15:25     ` 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=20200803004519.GZ6949@brightrain.aerifal.cx \
    --to=dalias@libc.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).