GNUMake 3.80 and failed malloc

Wacky compilation error:

Creating config.mak and config.h...
make(4162) malloc: *** vm_allocate(size=4272971776) failed (error code=3)
make(4162) malloc: *** error: can't allocate region
make(4162) malloc: *** set a breakpoint in szone_error to debug
make[1]: *** virtual memory exhausted. Stop.

This error has nothing to do with the particular code you’re compiling. Turns out GNU Make 3.80 has a bug, in which it sometimes sends a ridiculous requested block size to malloc(), which then fails to allocate the space.

The solution is to upgrade to GNUMake 3.81. Particularly pernicious on OS X 10.4 and Xcode 2.4.1.

2 Replies to “GNUMake 3.80 and failed malloc”

  1. How do you get Xcode to recognize a new version of make?

    Simply replacing /usr/bin/make doesn’t seem to have fixed my malloc crash.

    Thanks for the help!

  2. Are you on Xcode 2.4 on Tiger? Are you compiling within an Xcode project? Or separately on the command-line?

    For compiling within Xcode 2.4 on Tiger, there should only be one copy of gnumake – the one in /usr/bin. If you are in fact using a Makefile, this implies you’re using the external build function of Xcode, since Xcode itself has its own build system. In this case, check your Project’s Target(s) and overall Project configuration, and make sure it specifies the appropriate custom-compile script.

    If you are compiling on the command-line, check your path and make sure the make being picked up is the new make you installed. “which make” should show you the path being picked up, and “make –version” should show you the version used.

    For Xcode 3.0 on Leopard, there’s another copy of gnumake in /Developer/usr/bin, which is used by the dev tools. But Leopard should ship with GNU Make 3.81, so your particular problem in that case might be elsewhere.

Leave a Reply to yiming Cancel reply

Your email address will not be published. Required fields are marked *