RE: graceful mulit-threaded shutdown



So, I'm making progress.  after getting things set up to debug correctly, I
found that I was getting the "must shut down from main thread" error because
when I was calling CORBA_ORB_destroy.  my init_level was always greater than
0 so this was just returning and not shutting down.  So when my main
application tried to exit and force things then I was seeing the error.
This was due to the client that I was creating.  I initially had it
releasing it's reference to the orb, but this caused the assertion failure
in do_unref since the refs value became junk when the RootObject was no
longer a valid object.  Thanks Michael and Lace for the help and pointers to
figure this out. It didn't initially occur to me to destroy the object since
I knew it was still being referenced, although it does make sense to remove
the client's reference to it.

so...I called destroy from the client cleanup on the orb and this
decremented the init_level and allows things to nicely shutdown. 

but (I really wish there wasn't a "but"), I'm getting a few warnings:

** (process:3361): WARNING **: CORBA_ORB_destroy: ORB still has 2 refs.

** (process:3361): WARNING **: ORB: a total of 1 refs to ORB objects were
leaked

I'm pretty sure this has to do with me not completely cleaning up my client.
If I don't create the client, the warnings don't appear and it shuts down
without a peep.

I've started to walk though the duplicate and do_unref methods in the
debugger, but they are called quite a bit more than is simple to follow.  my
client stuff is fairly vanilla, I get a refence to the orb:

orb = CORBA_ORB_init(argc_ptr, argv, "orbit-local-mt-orb", ev);

I get my client (ior is :

gchar *objref=ior;
client = (CORBA_Object) CORBA_ORB_string_to_object (orb, objref, ev);

I can send data, but even if I don't i get the same results.

When I shutdown, before I do any cleanup for my server I to the following
clean up for the client:

CORBA_Object_release(client, ev);
CORBA_ORB_destroy(orb,&global_ev);

nothing too crazy, but I'm apparently missing something.  In the shutdown
method, the stack trace around the warnings are:

Breakpoint 1, ORBit_RootObject_release (obj=0x80e8688) at orbit-object.c:186
186                     do_unref (robj);
(gdb) bt
#0  ORBit_RootObject_release (obj=0x80e8688) at orbit-object.c:186
#1  0x401bb92c in ORBit_service_list_free_ref (key=0x401d9588,
    objref=0x80e8688, dummy=0x0) at corba-orb.c:173
#2  0x40245ee6 in g_hash_table_foreach () from /usr/lib/libglib-2.0.so.0
#3  0x401bce34 in CORBA_ORB_destroy (orb=0x80e5cb0, ev=0x4146364c)
    at corba-orb.c:1178
#4  0x41454f69 in CorbaServer_Run () at
Components/Maquet/maquet-server.c:151
#5  0x4144a161 in MaquetMgr::InitCorbaServerThread (this=0x80ce518)
    at Components/Maquet/MaquetMgr.cpp:1130
#6  0x4145350e in MaquetMgr::InitCorbaServerThreadStub (pThis=0x80ce518)
    at Components/Maquet/MaquetMgr.h:128
#7  0x4012e0b9 in EThread::ThreadStub (pParam=0x80ce578)
    at Base/EOS_linux.cpp:358
#8  0x402aa881 in pthread_start_thread () from /lib/i686/libpthread.so.0
#9  0x402aa985 in pthread_start_thread_event () from
/lib/i686/libpthread.so.0
(gdb) print total_refs
$18 = 8
(gdb) print robj->refs
$19 = 1
(gdb) c
Continuing.

Breakpoint 1, ORBit_RootObject_release (obj=0x80e84d0) at orbit-object.c:186
186                     do_unref (robj);
(gdb) print robj->refs
$20 = 1
(gdb) print total_refs
Continuing.

** (process:3417): WARNING **: CORBA_ORB_destroy: ORB still has 2 refs.

Breakpoint 1, ORBit_RootObject_release (obj=0x80e5cb0) at orbit-object.c:186
186                     do_unref (robj);
(gdb) bt
#0  ORBit_RootObject_release (obj=0x80e5cb0) at orbit-object.c:186
#1  0x401bcf11 in CORBA_ORB_destroy (orb=0x80e5cb0, ev=0x4146364c)
    at corba-orb.c:1226
#2  0x41454f69 in CorbaServer_Run () at
Components/Maquet/maquet-server.c:151
#3  0x4144a161 in MaquetMgr::InitCorbaServerThread (this=0x80ce518)
    at Components/Maquet/MaquetMgr.cpp:1130
#4  0x4145350e in MaquetMgr::InitCorbaServerThreadStub (pThis=0x80ce518)
    at Components/Maquet/MaquetMgr.h:128
#5  0x4012e0b9 in EThread::ThreadStub (pParam=0x80ce578)
    at Base/EOS_linux.cpp:358
#6  0x402aa881 in pthread_start_thread () from /lib/i686/libpthread.so.0
#7  0x402aa985 in pthread_start_thread_event () from
/lib/i686/libpthread.so.0
(gdb) print robj->refs
$22 = 3
(gdb) print total_refs
$23 = 3
(gdb)

Any thoughts?  after it goes through g_hash_table_foreach there are three
references left when I guess there should only be two.  any thoughts?

thanks,
Tyler

-----Original Message-----
From: Michael Meeks [mailto:michael@ximian.com]
Sent: Wednesday, November 12, 2003 12:18 PM
To: Tyler Kohn
Cc: 'Jan Kratochvil'; 'orbit-list@gnome.org'
Subject: RE: graceful mulit-threaded shutdown


Hi Tyler,

On Tue, 2003-11-11 at 19:59, Tyler Kohn wrote:
> The seg fault could very well be a bug in my code, somewhat unrelated as
> well.  But in any case I don't like to see the ** ERROR ** Must shut down
> from main thread.  

	Ah - well if it's a g_error then it's not going to be memory
corruption
related, it's just an assertion.

	Can you get a stack-trace of where precisely that's happening, I
can't
(off hand) see the g_error that's producing that in the code. I'm
slightly surprised the limitation is there really.

	Thanks,

		Michael.

-- 
 michael@ximian.com  <><, Pseudo Engineer, itinerant idiot



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]