ld: fatal error - cmalloc would have returned NULL

Rainer Emrich rainer@emrich-ebersheim.de
Fri Mar 11 12:34:00 GMT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mar  1 18:39, Corinna Vinschen wrote:
> On Mar  1 18:26, Rainer Emrich wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Any news on this issue?
>>
>> At the moment it's impossible to build libgcj during bootstrap of gcc!
>>
>> I tried 1.7.7-1 and the snapshot 20110227.
>>
>> Here some diagnostic:
>>
>>   288 117500220 [main] ld 5884 mmap64: 0x600E0000 = mmap()
>>  4283 117504503 [main] ld 5884 mmap64: addr 0, len 65536, prot 3, flags 22, fd
>> - -1, off 0
>>   306 117504809 [main] ld 5884 mmap64: 0x600D0000 = mmap()
>>  4296 117509105 [main] ld 5884 mmap64: addr 0, len 65536, prot 3, flags 22, fd
>> - -1, off 0
>>   290 117509395 [main] ld 5884 mmap64: 0x600C0000 = mmap()
>>  3883 117513278 [main] ld 5884 mmap64: addr 0, len 65536, prot 3, flags 22, fd
>> - -1, off 0
>>   416 117513694 [main] ld 5884 mmap64: 0x600B0000 = mmap()
>>  4503 117518197 [main] ld 5884 mmap64: addr 0, len 65536, prot 3, flags 22, fd
>> - -1, off 0
>
> This looks like a problem in ld.  It uses mmap a lot.  In fact it uses
> mmap so much that the memory allocation (which goes from top to bottom
> addresses) reaches the end of the Cygwin DLL itself and beyond that.
> And it doesn't mmap in a few big chunks, but rather in many small
> chunks.

This seems to be by design.

>
>>   490 117518687 [main] ld 5884 seterrno_from_win_error:
>> /ext/build/netrel/src/cygwin-snapshot-20110227-1/winsup/cygwin/cygheap.cc:145
>> windows error 487
>>    41 117518728 [main] ld 5884 geterrno_from_win_error: windows error 487 ==
>> errno 22
>>    42 117518770 [main] ld 5884 __set_errno: void* creturn(cygheap_types,
>> cygheap_entry*, unsigned int, const char*):265 val 12
>
> Every mmap call needs space on the cygheap, which is a special heap to
> keep inforamtion for later fork or exec calls.  The cygheap resides at
> the end of the Cygwin DLL.  If it's space is insufficient, the Cygwin
> DLL tries to extend it.  But it can't, because the memory slot is already
> taken by one of the many mmap calls.
>
>>    45 117518815 [main] ld 5884 mmap64: 0xFFFFFFFF = mmap()
>>    40 117518855 [main] ld 5884 __set_errno: void* sbrk(int):167 val 12
>>    36 117518891 [main] ld 5884 __set_errno: void __set_ENOMEM():304 val 12
>
> Therefore, the last mmap call fails and returns MAP_FAILED with errno
> set to ENOMEM.
>
>> - --- Process 5884, exception C0000005 at 0042903A
>
> And then ld crashes, because, apparently, it neglects to check the
> return value of mmap.

Yes it's a fault to not check the return value of mmap, but that wouldn't help
here either.

So, the solution for me was to increase the cygheap size. The maximum seems to
be 1792 MBytes. This solves the issue for boostrapping gcc with libjava enabled,
but may fail for even larger libraries.

Cheers

Rainer

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk16DhAACgkQoUhjsh59BL5aEwCgkachczdlzjh8yhDbPHoSYl5C
LMoAn0mH6tNOkvgjbeY1gVc8Ld9jogNr
=/uEs
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list