[omniORB] ORB_init after fork() no worky?

Dan Kegel dank@kegel.com
Wed, 20 Feb 2002 02:59:29 -0800


Problem:

  ORB_init() hangs if you fork first.

Platform:

  Red Hat 7.2 Intel.

Steps to repeat:

1. create test program:

#include <omniORB3/CORBA.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char **argv)
{
        pid_t childpid = fork();

        if (childpid == 0) {
                printf("Starting orb...\n");
                CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
                printf("Done.\n");
        } else {
                sleep(120);
        }
        return 0;
}

2. compile (your commandline will differ):

$ g++ -g -D__x86__  -I/opt/omniorb3/native/include  -L/opt/omniorb3/native/lib/i586_linux_2.0_glibc2.1 -lomniORB3 -ltcpwrapGK test.cc

3. run.  It will print just "Starting orb..." even though it should also print "Done."

4. Attach to child with gdb and get stack dump.  Looks something like this:
(gdb) bt
#0  0x401a7aa5 in __sigsuspend (set=0xbffff3d0) at ../sysdeps/unix/sysv/linux/sigsuspend.c:45
#1  0x402c3079 in __pthread_wait_for_restart_signal (self=0x402cbd60) at pthread.c:967
#2  0x402c324b in __pthread_create_2_0 (thread=0x804a2dc, attr=0xbffff5a0,
    start_routine=0x402b67bc <omni_thread_wrapper>, arg=0x804a2a8) at restart.h:34
#3  0x402b6b85 in omni_thread::start () from /opt/omniorb3/native/lib/i586_linux_2.0_glibc2.1/libomnithread.so.2
#4  0x402b6cd8 in omni_thread::start_undetached ()
   from /opt/omniorb3/native/lib/i586_linux_2.0_glibc2.1/libomnithread.so.2
#5  0x400ca970 in omni_strand_initialiser::attach ()
   from /opt/omniorb3/native/lib/i586_linux_2.0_glibc2.1/libomniORB3.so.0
#6  0x4008a029 in CORBA::ORB_init () from /opt/omniorb3/native/lib/i586_linux_2.0_glibc2.1/libomniORB3.so.0
#7  0x0804885f in main (argc=1, argv=0xbffff754) at test.cc:12
#8  0x40195507 in __libc_start_main (main=0x8048820 <main>, argc=1, ubp_av=0xbffff754, init=0x8048638 <_init>,
    fini=0x8048a1c <_fini>, rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbffff74c) at ../sysdeps/generic/libc-start.c:129

5. Smack table and say 'what up with that?'