From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Guillaume Morin <guillaume@morinfr.org>
Cc: fweimer@redhat.com, Siddhesh Poyarekar <siddhesh@sourceware.org>,
libc-alpha@sourceware.org
Subject: Re: [PATCH v8 03/10] Remove __morecore and __default_morecore
Date: Wed, 14 Jul 2021 19:43:47 +0530 [thread overview]
Message-ID: <45ba79b4-02e6-fae5-ae9b-db6c8a01aecb@gotplt.org> (raw)
In-Reply-To: <20210714125415.GA24678@bender.morinfr.org>
On 7/14/21 6:24 PM, Guillaume Morin wrote:
> On 14 Jul 12:31, Siddhesh Poyarekar wrote:
> I replied on the bug report becuase I had not seen this message.
>
> But basically, this breaks https://github.com/libhugetlbfs/libhugetlbfs/
> which is old (started in 2006) and commonly used library. The library
> is plugging its own morecore() implementation to use hugetlb pages to
> back the malloc heap.
Thanks, AFAICT, libhugetlbfs only uses __morecore and not the rest of
the interfaces. The thing is, __morecore and friends have been
deprecated for a year and building anything with __morecore ought to
give the deprecation warning.
> This is definitely not a win for all libhugetlbfs users. We have no
> equivalent solution. You're asking to find us an entire new malloc
> implementation if there is one (or write one?). We have no way of keep
> using glibc's malloc and hugetlb. I am not even sure there exists
> an equivalent replacement.
>
> I understand there is some security concern about malloc hooks but then
> why not allow morecore() substitution with a properly
> documented/supported interface? Most users already LD_PRELOAD
> libhugetlbfs so that would be an easy fix.
I don't think we would like to export a different interface to do the
same thing because it still doesn't allow us to clamp down further on
the system malloc implementation. Besides, the morecore hooking
interface is severely limited because it only affects the main arena.
Non-main arenas have their own allocation techniques and it doesn't
really make sense to have an interface to control just the main arena.
> You're claiming that it's subtly broken. I'd like to understand how and
> why this can't be fixed. Afaik people have been using libhugetlbfs's
> morecore() in production for 15+ years without any issue.
>
> The only issue I am aware of is the one I reported about 5 years ago
> (along with a reproducer and a patch). This problem can only be reached
> if trimming is enabled in the morecore implementation (it's disabled in
> libhugetlbfs for this very reason).
There is only the one known issue that you reported but that may well be
because the interface isn't well tested. There have been many changes
to malloc over the years and I cannot say for certain that the idea that
morecore could be anything other than brk has been consistently
considered. We don't have tests to verify that either. Further,
morecore limits its influence to the main arena and it is possible that
future changes could break this in ways that we cannot anticipate today.
Basically this is technical debt we've accumulated from the days when
malloc assumed single threaded programs and was incrementally hacked to
add in multi-threaded support. We'd like to clean this up.
The malloc code in glibc is quite general purpose and has little
dependency on libc internals. It may well be possible for you to copy
the source files over into libhugetlbfs to implement the interposer
within libhugetlbfs that does exactly what you need. In fact, that may
even allow you to extend hugetlbfs support to non-main arenas.
Siddhesh
next prev parent reply other threads:[~2021-07-14 14:14 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 7:38 [PATCH v8 00/10] malloc hooks removal Siddhesh Poyarekar via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 01/10] Make mcheck tests conditional on GLIBC_2.24 or earlier Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 02/10] Remove __after_morecore_hook Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 03/10] Remove __morecore and __default_morecore Siddhesh Poyarekar via Libc-alpha
2021-07-14 7:01 ` Siddhesh Poyarekar
2021-07-14 12:54 ` Guillaume Morin
2021-07-14 14:13 ` Siddhesh Poyarekar [this message]
2021-07-14 16:42 ` Guillaume Morin
2021-07-14 17:15 ` Carlos O'Donell via Libc-alpha
2021-07-14 17:42 ` Adhemerval Zanella via Libc-alpha
2021-07-14 18:37 ` Guillaume Morin
2021-07-14 18:48 ` Siddhesh Poyarekar
2021-07-14 18:31 ` Guillaume Morin
2021-07-14 17:32 ` Siddhesh Poyarekar
2021-07-14 18:25 ` Guillaume Morin
2021-07-14 18:43 ` Siddhesh Poyarekar
2021-07-14 18:51 ` Guillaume Morin
2021-07-17 22:03 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 04/10] Move malloc hooks into a compat DSO Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 05/10] mcheck: Wean away from malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-13 15:47 ` H.J. Lu via Libc-alpha
2021-07-14 2:44 ` Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 06/10] Simplify __malloc_initialized Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 07/10] mtrace: Wean away from malloc hooks Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 08/10] glibc.malloc.check: " Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 09/10] Remove " Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 7:38 ` [PATCH v8 10/10] mcheck Fix malloc_usable_size [BZ #22057] Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:04 ` Carlos O'Donell via Libc-alpha
2021-07-13 14:48 ` [PATCH v8 00/10] malloc hooks removal H.J. Lu via Libc-alpha
2021-07-13 15:41 ` Siddhesh Poyarekar via Libc-alpha
2021-07-17 22:03 ` Carlos O'Donell via Libc-alpha
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45ba79b4-02e6-fae5-ae9b-db6c8a01aecb@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=fweimer@redhat.com \
--cc=guillaume@morinfr.org \
--cc=libc-alpha@sourceware.org \
--cc=siddhesh@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).