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: "aurelien at aurel32 dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 14 Dec 2017 22:42:16 +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
--- Comment #1 from Aurelien Jarno <aurelien at aurel32 dot net> ---
I haven't done my test correctly on x86-64, errno is set to ENOMEM because the
malloc fails, so the behavior is perfectly normal. That said the same code
executed through ld.so on sparc64 and without ld.so succeed to allocate memory
and set errno to ENOMEM. I have tracked the errno setting to the sbrk function.
errno is 0
brk(NULL) = 0xfff8000100126000
brk(0xfff8000100148000) = 0xfff8000100126000
errno equals ENOMEM at this point
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xfff8000100492000
mmap(NULL, 33562624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xfff8000100592000
The above calls are the fallback to using mmap for memory allocation.
--
You are receiving this mail because:
You are on the CC list for the bug.