This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug malloc/22611] malloc might succeed and set errno to ENOMEM in case of heap allocation failure


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]