[omniORB] segmentation fault on shutdown with gcc 3.2.3

Janet Tvedt tvedt at noao.edu
Mon Mar 22 15:36:11 GMT 2004


I have an application that worked fine with an older compiler (gcc 2.96)
but generates a segmentation fault on shutdown when compiled with gcc
3.2.3.

I am using:
    omniORB 304 
    gcc 3.2.2
    RedHat 8.0

I've attached the output from turning up the trace level as well as the
source code that demonstrates the problem.  I should also mention that
if code is organized such that everything is one file (class
declaration, implementation and main program) then the segmentation
fault does not occur.  Perhaps this is just a coincidence.

Any ideas on what to do would be greatly appreciated.  I really need to
use the newer compiler.

Janet Tvedt
National Solar Observatory



OUTPUT
------
> Test1 -ORBtraceLevel 25

creating an object
initializing CORBA
omniORB: gateKeeper is tcpwrapGK 1.0 - based on tcp_wrappers_7.6
omniORB: scavenger : start.
omniORB: strand Ripper: start.
omniORB: Initialising omniDynamic library.
omniORB: Initialising incoming rope factories.
omniORB: strand Rope::incrRefCount: old value = 0
deleting an object
deleting Comm instance
numInstances=1
calling orb->shutdown()
omniORB: Preparing to shutdown ORB.
omniORB: Deinitialising omniDynamic library.
omniORB: Shutting-down incoming rope factories.
omniORB: strand Rope::decrRefCount: old value = 1
omniORB: tcpSocketMTfactory removeIncoming: Done
omniORB: scavenger : woken by poke()
omniORB: scavenger : exit.
omniORB: strand Ripper: exit.
omniORB: ORB shutdown is complete.
calling orb->destroy()
after orb->destroy()
exiting the program
omniORB: No more references to the ORB -- deleted.
omniORB: No more references to the BOA -- deleted.
Segmentation fault (core dumped)


Test1.cc
--------
#include <iostream>
using namespace std;
#include "Comm.h"


int main(int argc, char *argv[])
{
  cout << "creating an object" << endl;
  Comm *comm = new Comm(argc, argv);

  // Do stuff

  cout << "deleting an object" << endl;
  delete comm;
  cout << "exiting the program" << endl;
}


Comm.h
------
#ifndef INCcommh
#define INCcommh

using namespace std;
#include "omniORB3/Naming.hh"

class Comm
{
public:
  Comm(int argc, char **argv);
  ~Comm();

private:
      static CORBA::ORB_var               orb;
      static CORBA::BOA_var               boa;
      static CosNaming::NamingContext_var rootContext;
      static bool initialized;
      static bool connectedToNameService;
      static int numInstances;

};

#endif



Comm.cc
-------
#include "Comm.h"

using namespace std;
#include <iostream>

CORBA::ORB_var               Comm::orb;
CORBA::BOA_var               Comm::boa;
CosNaming::NamingContext_var Comm::rootContext;
bool                         Comm::initialized = false;
bool                         Comm::connectedToNameService = false;
int                          Comm::numInstances = 0;


Comm::Comm(int argc, char **argv)
{
   if(!initialized)
   {
      cout << "initializing CORBA" << endl;
      orb = CORBA::ORB_init(argc, argv, "omniORB3");
      boa = orb->BOA_init(argc, argv, "omniORB3_BOA");
      initialized = true;
   }

   // Increment instance count
   numInstances++;
}


Comm::~Comm()
{
   cout << "deleting Comm instance" << endl;
   cout << "numInstances=" << numInstances << endl;
   numInstances--;

   if(numInstances == 0)
   {
     try
     {
       //cout << "calling boa->destroy()" << endl;
       //boa->destroy();
       cout << "calling orb->shutdown()" << endl;
       orb->shutdown(true);
       cout << "calling orb->destroy()" << endl;
       orb->destroy();
       cout << "after orb->destroy()" << endl;
     }
     catch(CORBA::SystemException& e)
     {
       cout << "CORBA::SystemException& caught -- " << endl;
     }
     catch(...)
     {
       cout << "Caught unknown exception in file " << __FILE__ << ",
line: "<< __LINE__ << endl;
     }
   }
}





More information about the omniORB-list mailing list