Could it be because Sm_UnInit is getting called twice: once in your main routine by you, and then again in the object's destructor? If Sm_UnInit is doing some cleanup work, and then tries to do it again, the structures it is trying to clean up the second time would not longer be valid, and could cause a core dump. It seems to me that if you are calling in it the destructor, you probably shouldn't also be calling it directly in your "main" routine. (That said, you'll know the API that you're working with - this is just a thought...) Thanks, Lyle Taylor -----Original Message----- From: puneet girdhar [mailto:girdhar_puneet@xxxxxxxxx] Sent: Tuesday, September 16, 2003 12:45 PM To: gcc-help@xxxxxxxxxxx Subject: Regarding gcc debugging 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