|
ACE_THR_FUNC_RETURN thread_fun(void *arg)
{
TimerEventHandler hd;
SignalEventHandler sd(62);
ACE_Reactor::instance()->run_reactor_event_loop();
return 0;
}
int main(int argc,char *argv[])
{
if (0)
{
TimerEventHandler hd;
SignalEventHandler sd(62);
ACE_Reactor::instance()->run_reactor_event_loop();
}
else
{
ACE_Thread_Manager::instance()->spawn_n(1, thread_fun,
reinterpret_cast<void *>(ACE_Reactor::instance()));
ACE_Thread_Manager::instance()->wait();
}
return 0;
}
在启动线程来run_reactor_event_loop调试过程中,出现coredump.
根据coredump可知,是在reactor调用event_handler->handle_close方法时错误.
麻烦请问此类程序的标准写法应该如何?
以下附堆栈信息:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ae7635 in cancel_type (requires_reference_counting=<value optimized out>, dont_call=<value optimized out>, event_handler=<value optimized out>, this=<value optimized out>)
at ../../ace/Timer_Queue_T.cpp:441
441 event_handler->handle_close (ACE_INVALID_HANDLE,
(gdb) bt
#0 0x00007ffff7ae7635 in cancel_type (requires_reference_counting=<value optimized out>, dont_call=<value optimized out>, event_handler=<value optimized out>, this=<value optimized out>)
at ../../ace/Timer_Queue_T.cpp:441
#1 deletion (requires_reference_counting=<value optimized out>, dont_call=<value optimized out>, event_handler=<value optimized out>, this=<value optimized out>)
at ../../ace/Timer_Queue_T.cpp:466
#2 ACE_Timer_Heap_T<ACE_Event_Handler*, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>, ACE_Recursive_Thread_Mutex>::~ACE_Timer_Heap_T (
requires_reference_counting=<value optimized out>, dont_call=<value optimized out>, event_handler=<value optimized out>, this=<value optimized out>) at ../../ace/Timer_Heap_T.cpp:222
#3 0x00007ffff7ae4e92 in ACE_Select_Reactor_T<ACE_Reactor_Token_T<ACE_Token> >::close (this=0x60a8c0) at ../../ace/Select_Reactor_T.cpp:576
#4 0x00007ffff7b56e90 in ACE_Reactor::~ACE_Reactor (this=0x60a8a0, __in_chrg=<value optimized out>) at ../../ace/Reactor.cpp:117
#5 0x00007ffff7b5758a in ACE_Reactor::close_singleton () at ../../ace/Reactor.cpp:183
#6 0x00007ffff7b57e6b in ACE_Framework_Component_T<ACE_Reactor>::~ACE_Framework_Component_T (this=0x7ffff691e070, __in_chrg=<value optimized out>) at ../../ace/Framework_Component_T.cpp:21
#7 0x00007ffff7b09d01 in ACE_Framework_Repository::close (this=0x60d550) at ../../ace/Framework_Component.cpp:78
#8 0x00007ffff7b09d6d in ACE_Framework_Repository::~ACE_Framework_Repository (this=0x7ffff691e070, __in_chrg=<value optimized out>) at ../../ace/Framework_Component.cpp:40
#9 0x00007ffff7b09e20 in ACE_Framework_Repository::close_singleton () at ../../ace/Framework_Component.cpp:123
#10 0x00007ffff7b37454 in ACE_Object_Manager::fini (this=0x6041b0) at ../../ace/Object_Manager.cpp:751
#11 0x00007ffff7b37568 in ACE_Object_Manager::~ACE_Object_Manager (this=0x7ffff691e070, __in_chrg=<value optimized out>) at ../../ace/Object_Manager.cpp:417
#12 0x00007ffff7b372a5 in ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager (this=<value optimized out>, __in_chrg=<value optimized out>) at ../../ace/Object_Manager.cpp:882
#13 0x00007ffff6f7d3e5 in __cxa_finalize () from /lib64/libc.so.6
#14 0x00007ffff7ad4b86 in __do_global_dtors_aux () from /usr/local/lib/libACE-5.7.5.so
#15 0x0000000000000000 in ?? ()
(gdb) f 0
#0 0x00007ffff7ae7635 in cancel_type (requires_reference_counting=<value optimized out>, dont_call=<value optimized out>, event_handler=<value optimized out>, this=<value optimized out>)
at ../../ace/Timer_Queue_T.cpp:441
441 event_handler->handle_close (ACE_INVALID_HANDLE, |
|