MALLOC_CHECK_ use

uday@veritas.com uday@veritas.com
Tue Apr 25 07:00:00 GMT 2000


HI,

I have trouble using MALLOC_CHECK_ to check invalid memory frees in my
program.
When I don't export this variable my program gives sigsegv. Here is 
trace 

Program received signal SIGSEGV, Segmentation fault.
0x402e4e79 in chunk_free (ar_ptr=0x40379040, p=0xd99783e8) at
malloc.c:3030
3030    malloc.c: No such file or directory.
(gdb) bt
#0  0x402e4e79 in chunk_free (ar_ptr=0x40379040, p=0xd99783e8) at
malloc.c:3030
#1  0x402e4bfd in chunk_alloc (ar_ptr=0x40379040, nb=16) at malloc.c:2541
#2  0x402e440a in __libc_malloc (bytes=12) at malloc.c:2643
#3  0x805baac in __builtin_new (sz=12) at
../../gcc-2.95.2/gcc/cp/new1.cc:77
#4  0x401b7c49 in TRefObject<WideString>::TRefObject ()


But if I set the value of MALLOC_CHECK_=2, program works just fine !
According to the libc document the program should abort when invalid
memory operation is done. 

Why I am doing this is, I suspect the invalid memory operation is done 
some time before I received sigsegv. When I set MALLOC_CHECK_=2, I should 
get that instance.

I am using sigstl in my program. I am running it on RH6.2 with gcc 2.95.2.

Thanks for the help,
uday



More information about the Gcc-help mailing list