1833017 Members
2242 Online
110048 Solutions
New Discussion

core dump on getenv

 
Michael Murphy_2
Frequent Advisor

core dump on getenv

We are getting a core dump on the getenv call of an older application we are porting to 11.0 64 bit. THis was a c application. We are compiling with -Ae and -DA2.0W. Can't find any patches for libc that mention this behavior - any clues?
1 REPLY 1
Mike Stroyan
Honored Contributor

Re: core dump on getenv

Your code might have a 64-bit porting issue. Perhaps you passed in a bad pointer or assigned the result of getenv to a bad address for a pointer. You could see that by running the gdb debugger on the program and core file and using the 'disas' and 'info reg' commands to see where the crash happened and what data it was working on.
Another surprisingly common way to crash in getenv is to use putenv with a string constant that is defined in a shared library, then unload that shared library. The string address is unmapped, so the next getenv call gets a segmentation fault.