*** glibc detected *** malloc()

Occasional Contributor

*** glibc detected *** malloc()


When I'm porting my C++ application from HP-UX 11i ( aCC: HP ANSI C++ B3910B A.03.65 ) to linux ( Red Hat Enterprise Linux AS release 4 (Nahant Update 4, gcc (GCC) 3.4.4), during the runtime I'm getting the following error :

*** glibc detected *** malloc(): memory corruption: 0x082051f8 ***

I tired searching a lot on the net and changed the program accordingly but no success. The same code is working fine on HP.

Any help pls.

dirk dierickx
Honored Contributor

Re: *** glibc detected *** malloc()

yes, the glibc from the last few versions of RH tries to capture as many problems with memory allocations without causing to much overhead.
libc on hpux does not do this, it will allow you to do these kind of things, but the results are unpredictable in this case and in fact this 'bug' in your code could be used by hackers.
luckily there are OSS tools available to help you in your quest to find your mistake.

the best in this case is valgrind:

from their site:
Valgrind is an award-winning suite of tools for debugging and profiling Linux programs. With the tools that come with Valgrind, you can automatically detect many memory management and threading bugs, avoiding hours of frustrating bug-hunting, making your programs more stable.