Sun 23 Oct 2005 06:09:51 AM UTC, original submission:
# uname -a
Linux tania 2.6.12.1-vs2.0-rc4 #1 Fri Jul 1 08:55:19 CEST 2005 i686 AMD Duron(tm) processor AuthenticAMD GNU/Linux
# ls|wc -l
35396
# find
.
find: .: Cannot allocate memory
Using ltrace -S, here is the part that cause the above error:
23148 realloc(0xb7e45008, 524288 <unfinished ...>
23148 SYS_mremap(0xb7e45000, 266240, 528384, 1, 528384) = -12
23148 SYS_mmap2(0, 528384, 3, 34, -1) = 0xb7dc4000
23148 SYS_munmap(0xb7e45000, 266240) = 0
23148 <... realloc resumed> )
The SYS_mremap call return -12 (ENOMEM) which cause errno to be set to
this value. However, realloc then try mmap2 (and unmap previous memory
block.) What happen is that realloc succeed, but also set errno (which
is permitted by the C standard if I understand correctly.)
But, savedirinfo.c/xsavedir call extendbuf (which call realloc) and
keep errno to its value even if memory was correctly extended. At the
end of the xsavedir function, errno value is tested and cause result
to be discarded and NULL returned.
I think this behavior is wrong. In extendbuf, the errno value should
be reset to its initial value if it succeed.
(Unrelated: the 'tar' command seem to be affected by this behavior too.)
|