------- Comment #2 from charles dot w dot lambert at gmail dot com 2008-02-27 16:32 ------- I can confirm this bug against gcc 4.2.3 and gcc 4.3.0 on os x (10.5.2). Apparently apple has changed the way that putenv is handled. From the `man 3 getenv` page i quote: "COMPATIBILITY putenv() no longer copies its input buffer. This often appears in crash logs as a crash in getenv(). Avoid passing local buffers or freeing the memory that is passed to putenv(). Use setenv(), which still makes an internal copy of its buffers."
I have examined the source code and found the error to be in the file <base_path>/gcc/ada/env.c near line 179 in __gnat_setenv() with the following code: 179: putenv (expression); 180: #if (defined (__FreeBSD__) && (__FreeBSD__ < 7)) \ 181: || defined (__APPLE__) || defined (__MINGW32__) \ 182: ||(defined (__vxworks) && ! defined (__RTP__)) 183: /* On some systems like FreeBSD 6.x and earlier, MacOS X and Windows, 184: putenv is making a copy of the expression string so we can free 185: it after the call to putenv */ 186: free (expression); 187:#endif On current versions of OS X (10.5 on my system). This call to free on line 186 is causing all calls to getenv() after calling __gnat_setenv() to return NULL This happens when calling gnatmake during the Initialize procedure in make.adb near line 6645 with the following code: 6645: declare 6646: PATH : constant String := 6647: Prefix & Directory_Separator & "bin" & 6648: Path_Separator & 6649: Getenv ("PATH").all; 6650: begin 6651: Setenv ("PATH", PATH); 6652: end; Setenv here is located in <base_path>/gcc/ada/s-os_lib.adb near line 2285 Setenv imports __gnat_setenv I can confirm that removing the call to free fixes the problem in this bug report. However i do not know what proper preprocessor flags to use. -- charles dot w dot lambert at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |charles dot w dot lambert at | |gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33857