This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug malloc/22611] malloc might succeed and set errno to ENOMEM in case of heap allocation failure
- From: "carlos at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 14 Dec 2017 23:58:12 +0000
- Subject: [Bug malloc/22611] malloc might succeed and set errno to ENOMEM in case of heap allocation failure
- Auto-submitted: auto-generated
- References: <bug-22611-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=22611
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |carlos at redhat dot com
--- Comment #2 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Aurelien Jarno from comment #1)
> brk(0xfff8000100148000) = 0xfff8000100126000
This should result in __brk returning -1 with errno set to ENOMEM.
That in turn should trigger mmap fallback.
I don't see any case in the existing code where we save/restore errno around a
failed call to brk.
We cannot set errno to zero, because that's not allowed, we need to save it,
and restore it if MORECORE fails, and we need to retry with something else that
will succeed.
I expect nobody tests this fallback path all that thoroughly.
Can you create a test case that adds an mmap just after the brk region, this
should cause a failure to happen. The test case will need to call brk to figure
out *where* the current break is, then add some space, then place an mmap
there, and see if the expanding sbrk fails.
--
You are receiving this mail because:
You are on the CC list for the bug.