Regarding gcc debugging

Burak Serdar bserdar@nc.rr.com
Wed Sep 17 02:01:00 GMT 2003


You probably have a corrupt heap, as the sigsegv arrives after main 
returned, the destructor is called, and apparently, after that 
destructor is returned. The reason is probably in some other place in 
your code.

puneet girdhar wrote:
> Hi,
> I am trying to debug a C++ program with gdb on Linux
> AS 2.1. when the program terminates,the destructor is
> called and this destructor in turn calls the
> un-initializer routine.After the Un-inilization
> routine is over it does not give core dump.But then it
> goes in main and gives core dump.
> 
>       ***************source code starts***********
> 
> void SmAgentExample::Sm_UnInit( )
> {
>     int iResult;
> 
>     printf("Value of pSmApiHandle inside Sm_UnInit is
> %x\n",pSmApiHandle);
> 
>     if ( NULL != pSmApiHandle ) {
> 
>         Sm_Logout();
>         //
>         // UnInitialize the Agent API
>         //
>         // Return values:
>         //      SM_AGENTAPI_SUCCESS
>         //      SM_AGENTAPI_FAILURE
>         //      SM_AGENTAPI_NOCONNECTION
>         iResult = Sm_AgentApi_UnInit( &pSmApiHandle );
>         if (SM_AGENTAPI_SUCCESS==iResult)
>             printf (  "Agent Released\n" );
>         else if (SM_AGENTAPI_FAILURE==iResult)
>             printf ( "UnInitialzation Failed\n" );
>         else if (SM_AGENTAPI_NOCONNECTION==iResult)
>             printf ( "Timeout for server response!\n"
> );
>     }
>         printf("I am here\n");
>     login = 0;
> }
> 
> SmAgentExample::~SmAgentExample()
> {
> 
>     pSmApiHandle = NULL;
>     printf("Inside destructor\n");
>     Sm_AgentApi_FreeAttributes(iNumAttributes,
> pAttributes);
>     printf("Before Sm_UnInit function\n");
>     Sm_UnInit( );
> }
> 
> int main()
> {
>    .....
>    .....
>    while{
>    switch(input)
>    case 'q' :
>           break;
>   .......
>    }
>    a.Sm_UnInit( );
>    printf ( "Done, thank you for Testing the API.\n"
> );
>    return 0;
> }
>      **************source code ends***********
> 
>      -------------output of gdb---------
> 
> FTP> q
> Breakpoint 1, SmAgentExample::Sm_UnInit() (this=0x1)
> at smagentexample.cpp:220
> 220     {
> (gdb) s
> 0x0804a601 in main ()
> (gdb) s
> Single stepping until exit from function main, 
> which has no line number information.
> Value of pSmApiHandle inside Sm_UnInit is 8052728
> Agent Released
> I am here
> Done, thank you for Testing the API.
> Inside destructor
> Before Sm_UnInit function
> 
> Breakpoint 1, SmAgentExample::Sm_UnInit()
> (this=0xbffe5a50) at smagentexample.cpp:220
> 220     {
> (gdb) s
> 0x0804a601 in main ()
> (gdb) s
> Single stepping until exit from function main, 
> which has no line number information.
> Value of pSmApiHandle inside Sm_UnInit is 0
> I am here
> 
> Breakpoint 3, main () at smagentexample.cpp:778
> 778     }
> (gdb) s
> 0x4021a727 in __libc_start_main () from /lib/libc.so.6
> (gdb) s
> Single stepping until exit from function
> __libc_start_main, 
> which has no line number information.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x403c7112 in ?? (). When i gave bt command it gave:
> 
> (gdb) bt
> #0  0x403c7112 in ?? ()
> #1  0x4021a730 in __libc_start_main () from
> /lib/libc.so.6
> 
> -------------output of gdb---------------------
> 
> Can anybody give any ptrs on this that why it is
> dumping core. Thanks in advance.
> 
> Regards
> Puneet
> 
> 
> ________________________________________________________________________
> Yahoo! India Matrimony: Find your partner online.
> Go to http://yahoo.shaadi.com
> 



More information about the Gcc-help mailing list