shutdown() SEGVs (was Re: [omniORB] atexit, exit, _exit, and ORB::destroy())

Huw Rogers count0@building2.co.jp
Sat, 13 Jan 2001 13:40:28 +0900


I'm getting consistent crashes (SEGVs)
on both Linux and Solaris in shutdown().
(omniORB 3.0.2, RedHat 7.0 and Solaris 8).
This is a problem since I want to embed
the code making use of omniORB in a
web server. It cannot leak memory
and it must clean up after itself.

Enclosed is some diagnostic information from Linux.
Before I shutdown I set the omniORB trace level to
25 and install a SEGV handler that waits
forever so I can attach gdb to the specific
thread that SEGV'd and get a stack trace.

I took a look at the omniORB code myself, and I
wonder if omniORB_Ripper::run_undetached()
is interfering with Rope::CutStrands().
There certainly seems to be some inconsistency
in the manner of locking and
iterating through ropes and strands as
they are being disposed of. The omniORB_Ripper
code looks dubiously thread unsafe
to the casual observer. But unfortunately
I don't understand it fully and am also
working under a deadline.

If anyone has any advice or (hope!) a patch,
I would much appreciate it.

    -Huw

Log:

omniORB: Preparing to shutdown ORB.
omniORB: Starting an ORB shutdown thread.
omniORB: throw omniConnectionBroken from tcpSocketMTfactory.cc:1058
omniORB: tcpSocketMTfactory Worker: #### Connection closed.
omniORB: tcpSocketMTfactory Worker: exit.
omniORB: tcpSocketStrand::~Strand() close socket no. 11
omniORB: ORB shutdown already in progress -- waiting.
omniORB: ORB shutdown thread started.
omniORB: Deinitialising omniDynamic library.
omniORB: Destroying POA(RootPOA).
omniORB: Destroying POA(KitDConference).
omniORB: Deactivating all POA(KitDConference)'s objects.
omniORB: Waiting for requests to complete on POA(KitDConference).
omniORB: Etherealising POA(KitDConference)'s objects.
omniORB: Destruction of POA(KitDConference) complete.
omniORB: Destroying POA(KitDConferenceDSP).
omniORB: Deactivating all POA(KitDConferenceDSP)'s objects.
omniORB: Waiting for requests to complete on POA(KitDConferenceDSP).
omniORB: Etherealising POA(KitDConferenceDSP)'s objects.
omniORB: Destruction of POA(KitDConferenceDSP) complete.
omniORB: Destroying POA(KitDIsdnLine).
omniORB: Deactivating all POA(KitDIsdnLine)'s objects.
omniORB: Waiting for requests to complete on POA(KitDIsdnLine).
omniORB: Etherealising POA(KitDIsdnLine)'s objects.
omniORB: Destruction of POA(KitDIsdnLine) complete.
omniORB: Destroying POA(KitDVoiceDSP).
omniORB: Deactivating all POA(KitDVoiceDSP)'s objects.
omniORB: Waiting for requests to complete on POA(KitDVoiceDSP).
omniORB: Etherealising POA(KitDVoiceDSP)'s objects.
omniORB: Destruction of POA(KitDVoiceDSP) complete.
omniORB: Destroying POA(MvBase).
omniORB: Deactivating all POA(MvBase)'s objects.
omniORB: Waiting for requests to complete on POA(MvBase).
omniORB: Etherealising POA(MvBase)'s objects.
omniORB: Destruction of POA(MvBase) complete.
omniORB: Deactivating all POA(RootPOA)'s objects.
omniORB: Deactivating: root<0> (has local refs).
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: strand Rope::incrRefCount: old value = 0
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: Waiting for requests to complete on POA(RootPOA).
omniORB: Etherealising POA(RootPOA)'s objects.
omniORB: omniLocalIdentity deleted.
omniORB: Stopping incoming rope factories.
omniORB: tcpSocketStrand::real_shutdown() fd no. 7 Done
19488: SEGV
  #3  __pthread_alt_unlock (lock=0x80a7e78) at spinlock.c:581
  #4  0x402fe0f4 in __pthread_mutex_unlock (mutex=0x80a7e68) at
mutex.c:194
  #5  0x402ea234 in omni_mutex::unlock ()
     from /opt/omniORB3/lib/libomnithread.so.2
  #6  0x400ec5f8 in Strand::decrRefCount ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #7  0x40117929 in omniORB_Ripper::run_undetached ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #8  0x402ea975 in omni_thread_wrapper ()
     from /opt/omniORB3/lib/libomnithread.so.2
  #9  0x402fda20 in pthread_start_thread (arg=0xbf7ffc00) at
manager.c:274
omniORB: throw omniConnectionBroken from tcpSocketMTfactory.cc:1058
19652: SEGV
  #4  0x402fe0f4 in __pthread_mutex_unlock (mutex=0x80a7e68) at
mutex.c:194
  #5  0x402ea234 in omni_mutex::unlock ()
     from /opt/omniORB3/lib/libomnithread.so.2
  #6  0x400ed40f in Strand_iterator::~Strand_iterator ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #7  0x400ecef7 in Rope::CutStrands () from
/opt/omniORB3/lib/libomniORB3.so.0
  #8  0x400f86b5 in tcpSocketIncomingRope::cancelThreads ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #9  0x400f794d in tcpSocketMTincomingFactory::stopIncoming ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #10 0x400b597a in omniObjAdapter::adapterInactive ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #11 0x400be812 in omniOrbPOA::do_destroy ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #12 0x400b8d26 in omniOrbPOA::destroy ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #13 0x400bf6cc in omniOrbPOA::shutdown ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #14 0x400d78c7 in omniOrbORB::actual_shutdown ()
     from /opt/omniORB3/lib/libomniORB3.so.0
  #15 0x400d7a12 in shutdown_thread_fn () from
/opt/omniORB3/lib/libomniORB3.so.0
  #16 0x402ea91f in omni_thread_wrapper ()
     from /opt/omniORB3/lib/libomnithread.so.2
  #17 0x402fda20 in pthread_start_thread (arg=0xbf1ffc00) at
manager.c:274
omniORB: scavenger : scanning connections
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketStrand::~Strand() close socket no. 16
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: strand Rope_iterator: delete unused Rope.
omniORB: tcpSocketStrand::~Strand() close socket no. 15
omniORB: tcpSocketMTfactory ~tcpSocketOutgoingRope: called
omniORB: tcpSocketMTfactory Rendezvouser: waiting on shutdown state to
change to NO_THREAD.
omniORB: throw omniConnectionBroken from tcpSocketMTfactory.cc:1058