Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

*** glibc detected *** malloc()

sumanth_2
Occasional Contributor

*** glibc detected *** malloc()

Hi,

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.

Regards,
sumanth
1 REPLY
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:
http://valgrind.org/

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.