mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Timo Teras <timo.teras@iki.fi>
To: musl@lists.openwall.com
Cc: u-igbb@aetey.se
Subject: Re: malloc not behaving well when brk space is limited?
Date: Sat, 29 Mar 2014 19:15:02 +0200	[thread overview]
Message-ID: <20140329191502.072c07f9@vostro> (raw)
In-Reply-To: <20140329170032.GJ8221@example.net>

On Sat, 29 Mar 2014 17:00:32 +0000
u-igbb@aetey.se wrote:

> Background:
>  Compiling a native musl-based toolchain for ia32 on Linux 2.6+.
>  Using the standalone dynamic loader mode.
>  (The latter seems to lead to a quite limited heap space, by kernel
>  behaviour/design)
> 
> I encounter out of memory errors. A look at the malloc source does not
> find any fallback to mmap when heap is exhausted. What would you
> suggest as a suitable approach to make it work?
> 
> Somebody has possibly already encountered and solved this with musl?

Yes, been there done that. I patched kernel.

The thread that follows on sending the patch upstream is e.g. at:
https://groups.google.com/forum/#!msg/linux.kernel/mOf1EWrrhZc/bl96BAE4fyQJ

Also using grsec kernel would fix the issue mostly, since grsec creates
"better" memory layout for PIE binaries.

> I see also reports about a related out of memory problem with
> pae-executables which means a solution might help many musl users.
> 
> The other standard libraries I am using (glibc, uclibc) seem to
> happily switch to allocation from mmap() when the heap is full. I
> understand that this costs some code and performance but a breakup is
> no good either.
> 
> Any ideas? Maintaining and using an external libmalloc or substituting
> malloc in musl? This feels like quite a burden...
> (Would musl internal calls to malloc notice the external library
> and resolve to its entry points instead of the internal malloc?)

musl does not support external malloc. musl internal calls to
malloc() are not overridable.

I think you need to fix kernel. Rewrite allocator in musl. Or add the
fallback code to mmap - but dalias said it's "hard". Perhaps still
should be still reconsidered.

- Timo


  reply	other threads:[~2014-03-29 17:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-29 17:00 u-igbb
2014-03-29 17:15 ` Timo Teras [this message]
2014-03-29 17:22   ` Rich Felker
2014-03-29 18:02     ` u-igbb
2014-03-29 18:56       ` Rich Felker
2014-03-29 19:54         ` u-igbb
2014-03-29 20:25           ` Rich Felker
2014-03-29 20:54             ` u-igbb
2014-03-31  4:51               ` 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=20140329191502.072c07f9@vostro \
    --to=timo.teras@iki.fi \
    --cc=musl@lists.openwall.com \
    --cc=u-igbb@aetey.se \
    /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).