[tao-bugs] Multithreaded, multi-orb example fails assert in ACE_TSS_Cleanup::thread_release

Mark Boriack mark.boriack at tena-sda.org
Tue Jun 28 10:02:48 CDT 2016


To: tao-bugs at list.isis.vanderbilt.edu
Subject: Multithreaded, multi-orb example fails assert in ACE_TSS_Cleanup::thread_release 

    TAO VERSION: 2.3.4
    ACE VERSION: 6.3.4

    HOST MACHINE and OPERATING SYSTEM:
    Windows 7 visual studio 2010. Also Windows 10 visual studio 2015,
    both 32 and 64 bit debug. Latest patch levels for all systems and 
    visual studio versions.

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
    COMPILER NAME AND VERSION (AND PATCHLEVEL):

    THE $ACE_ROOT/ace/config.h FILE:
    config-win32.h

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE:

    CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
    (used by MPC when you generate your own makefiles):

    AREA/CLASS/EXAMPLE AFFECTED:
    ACE_TSS_Cleanup

    DOES THE PROBLEM AFFECT:
        COMPILATION?
            No
        LINKING?
            No
        EXECUTION?
          Simple server application using multiple orbs dies with assert
          failure in ACE_TSS_Cleanup::thread_release.
        OTHER (please specify)?

    SYNOPSIS:
    This is a problem that has been present at least since TAO 2.2.4 and
    is still present in 2.3.4. We have a simple server application based
    on TAO/tests/Param_Test/server.cpp that causes an assert failure during 
    shutdown.

    DESCRIPTION:
    This is a problem that has been present at least since TAO 2.2.4 and
    is still present in 2.3.4. We have a simple server application based
    on TAO/tests/Param_Test/ that causes and assert failure during 
    shutdown. The statement is ACE_ASSERT (info.thread_count_ > 0);

    REPEAT BY:
    Replace server.cpp in TAO/tests/Param_Test with the included code.
    Only the server.exe application needs to be run. It fails on shutdown.

    SAMPLE FIX/WORKAROUND:
    In practice we replace the assert with a warning and execution
    continues.
    
// server.cpp based on TAO/tests/Param_Test/server.cpp

//=============================================================================
/**
 *  @file    server.cpp
 *
 *  $Id: server.cpp 95437 2012-01-16 09:12:46Z johnnyw $
 *
 *  @author Aniruddha Gokhale
 */
//=============================================================================


#include "param_test_i.h"
#include "tao/Codeset/Codeset.h"
#include "tao/debug.h"
#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_stdio.h"
#include "ace/Thread_Manager.h"
#include "ace/Guard_T.h"
#include "ace/Task.h"
#include "Winsock2.h"

CORBA::ORB_var orb;
ACE_SYNCH_MUTEX m1;

class Other : public ACE_Task_Base
{
public:
  Other(ACE_Thread_Manager * mgr)
    : ACE_Task_Base(mgr)
  {
  }
  virtual int svc();
};

int
Other::svc()
{
  m1.acquire();
  std::cout << "Other thread running" << std::endl;
  orb->destroy();
  std::cout << "Other thread destroyed orb" << std::endl;

  char * myargv = { 0 };
  int a = 0;
  
  orb=CORBA::ORB_init(a, &myargv, "Second ORB");
  std::cout << "Other thread created next orb" << std::endl;
  m1.release();
  return 0;
}

int
main( int argc, char * argv[] ) 
{
  std::auto_ptr<Param_Test_i> param_test;

  WSADATA wsaData;
  int iResult = WSAStartup( MAKEWORD(2, 2), &wsaData );
  if( iResult != 0 )
  {
    std::cout << "WSAStartup failed: " << iResult << std::endl;
  }

  try
  {
    orb=CORBA::ORB_init (argc, argv, "First ORB");
    
    CORBA::Object_var obj;
    obj = orb->resolve_initial_references ("RootPOA");
    PortableServer::POA_var rootPOA = PortableServer::POA::_narrow (obj.in());

    param_test.reset(new Param_Test_i("unknown", orb.in()));
      
    PortableServer::ObjectId_var id =
      PortableServer::string_to_ObjectId ("param_test");
    rootPOA->activate_object_with_id (id.in (), param_test.get());
    PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager();

    poa_manager->activate ();

    // acquire mutex to prevent Other thread from acting until
    // everything is set up
    m1.acquire();
    ACE_Time_Value tv(1,0);
    orb->run( tv );

    ACE_Thread_Manager *thr_mgr = ACE_Thread_Manager::instance ();
    Other task1( thr_mgr );

    std::cout << "Main: activate other task" << std::endl;
    task1.activate();

    // let the Other thread destroy the ORB
    m1.release();

    // now wait until the Other thread has completed
    thr_mgr->wait();

    std::cout << "Main: thr_mgr::wait done" << std::endl;

    // destroy the second ORB, and wait the OS_NS_Thread assertion
    orb->destroy();
  }
  catch (const CORBA::Exception& ex)
  {
    ex._tao_print_exception ("System Exception");
    return -1;
  }
  catch ( std::exception const & ex)
  {
    std::cerr << "std exception: " << ex.what() << std::endl;
    return -1;
  }

  return 0;
}



More information about the tao-bugs mailing list