executable causing core
Hi,
One of my executables is coring. I tried to debug the core using gdb. I got the following stack trace:-
gdb reconProcess core
> Wildebeest is free software and you are welcome to distribute copies
> of it under certain conditions; type "show copying" to see the
> conditions.
> There is absolutely no warranty for Wildebeest; type "show warranty"
> for details.
>
> Hewlett-Packard Wildebeest 1.0 (based on GDB 4.16) (built for PA-RISC
> 1.1 or 2.0 (narrow), HP-UX 11.00) Copyright 1996, 1997 Free Software
> Foundation, Inc...
> Core was generated by `reconProcess'.
> Program terminated with signal 11, Segmentation fault.
>
> warning: The shared libraries were not privately mapped; setting a
> breakpoint in a shared library will not work until you rerun the
> program.
>
> #0 0xc0198090 in _sigfillset () from /usr/lib/libc.2 #0 0xc0198090
> in _sigfillset () from /usr/lib/libc.2
> (gdb) bt
> #0 0xc0198090 in _sigfillset () from /usr/lib/libc.2
> #1 0xc0195bbc in _sscanf () from /usr/lib/libc.2
> #2 0xc019b294 in malloc () from /usr/lib/libc.2
> #3 0x1eb60 in stradd (dest=0x77ff1f48, src=0x403dddac "0") at
> aogutils.cpp:24
> #4 0x2d534 in AOG_Action::fcifTo (this=0x403ddd40)
>at /cm41/rel41/rel/bgp/interfaces/aog/AOGActionRecon.cpp:5363
> #5 0x18fd4 in AOG_Order::FCIF4VDN (this=0x4009e560, target=1001) at
> AOGOrderRecon.cpp:1955
> #6 0x1865c in AOG_Order::AddVDN (this=0x4009e560) at
> AOGOrderRecon.cpp:1729
> #7 0x1470c in AOG_ROrder::buildFCIF (this=0x4009e560, custID=135714)
> at AOGOrderRecon.cpp:479
> #8 0x115ac in processRecon (Tn=@0x77ff1178, Oe=@0x4032f108)
>at /cm41/rel41/rel/bgp/interfaces/aog/reconProcess.cpp:445
> #9 0x123f8 in tnType (Num=0x77ff08d8 " 1") at
> /cm41/rel41/rel/bgp/interfaces/aog/reconProcess.cpp:605
> #10 0xe0b0 in main (argc=5, argv=0x77ff060c) at
> /cm41/rel41/rel/bgp/interfaces/aog/reconProcess.cpp:310
> (gdb)
From the stack trace, it seems that there is a problem in the stradd function where it makes a call to malloc(). The following is the code for function stradd():-
/*CODE - stradd()*/
// This funciton adds src to dest
void stradd( char **dest, const char *src )
{
char *tmp;
if( src == NULL )
return;
if( *dest == NULL )
{
tmp = (char *)[b]malloc[/b]( strlen( src ) + 1 );
strcpy( tmp, src );
}
else
{
tmp = (char *)malloc( strlen( *dest ) + strlen( src ) + 1 );
strcpy( tmp, *dest );
strcat( tmp, src );
free(*dest);
}
*dest = tmp;
}
The Highlighted malloc call seems to be giving a problem.
Could anyone help me out.
Thanks in Advance.

