application crash on exit(0)

From: Anis (anismo_at_yahoo.com)
Date: 05/30/04


Date: Sun, 30 May 2004 16:07:35 GMT

Hello,

I am getting an application crash when exit(0) is called after forking to
make
a daemon process.

The program uses standard method for daemonizing and uses a bunch of shared
libraries.

   // Dissociate from the terminal
    if( ( pid = fork() ) != 0 )
    {
        // Parent Process
        if( -1 == pid )
        {
            // Serious problem , lets bail out

            raise(SIGTRAP);
        }

        // Terminate Parent
        exit( 0 );
    }
    // Become Session Leader
    // The child is still the process the group leader.
    setsid();

    // Fork again so that the child is not the process group leader.
    if( ( pid = fork() ) != 0 )
    {
        if( -1 == pid )
        {

            raise(SIGTRAP);

        // Terminate Parent
        exit( 0 );
    }

But when, the parent process calls exit( 0 ), I have occasional (not always)
crashes dumping core. The code is running
on ppc/linux (Linux version 2.4.18-rc4 / gcc version 3.2.3 20030401 )

#0 0x0f8c387c in __FRAME_END__ () from /home/bt42/export/ppc/lib/libsv.so
#1 0x0f8b0004 in __static_initialization_and_destruction_0(int, int)
(__initialize_p=1207960804, __priority=263335744)
    at /home/bt42/export/ppc/fips/include/evenmgt.H:594
#2 0x0f8b0178 in _GLOBAL__D_g_svCompBufferSize () at
/home/bt42/export/ppc/include/evenmgt.H:594
#3 0x0f875200 in __do_global_dtors_aux () from
/home/bt42/export/ppc/lib/libsv.so
#4 0x0f8b08c0 in _fini () from /home/bt42/export/ppc/lib/libsv.so
#5 0x3000bc00 in _dl_fini () at dl-fini.c:169
#6 0x0fb22c78 in exit (status=0) at exit.c:58
#7 0x10004c44 in survDaemonize () at /home/bt42/surv/clienthandler.C:508
#8 0x1000475c in main () at /home/bt42/surv/clienthandler.C:208

I googled for similar problem and I did notice that was due to the runtime
linker sometimes running the _fini sections of dynamic libraries in the
wrong order at exit.

Can someone please help me debug this problem or if this is a known problem,
can I get a confirmation of that? I highly appreciate any
help on this issue..
If any other information is required, I will be more than happy to provide.

Thanks in advance and REgards
Anis