From f3b3cfd76577ea5e3cd2eeac24098415fe22e23d Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 13 Jan 2021 14:09:11 +0100 Subject: [PATCH] SIGSEGV at load time of _SMeshHelper.so --- src/SMESH_I/SMESH_Gen_i.cxx | 26 +++++++++++++++----------- src/SMESH_I/SMESH_Gen_i.hxx | 3 ++- src/SMESH_SWIG/CMakeLists.txt | 1 + src/SMESH_SWIG/SMeshHelper.cxx | 4 ++-- src/SMESH_SWIG/SMeshHelper.h | 4 +++- src/SMESH_SWIG/SMeshHelper.i | 9 ++++++++- src/SMESH_SWIG/smeshBuilder.py | 3 ++- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index ad5b17f8c..4a8e9b303 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -330,7 +330,8 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId* contId, const char* instanceName, - const char* interfaceName ) + const char* interfaceName, + bool checkNS) : Engines_Component_i( orb, poa, contId, instanceName, interfaceName ) { @@ -356,21 +357,24 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, // find out mode (embedded or standalone) here else // meshes created before calling SMESH_Client::GetSMESHGen(), which calls // SMESH_Gen_i::SetEmbeddedMode(), have wrong IsEmbeddedMode flag - if ( SALOME_NamingService* ns = GetNS() ) + if(checkNS) { - CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" ); - SALOME::Session_var session = SALOME::Session::_narrow( obj ) ; - if ( !session->_is_nil() ) + if ( SALOME_NamingService* ns = GetNS() ) { - CORBA::String_var str_host = session->getHostname(); - CORBA::Long s_pid = session->getPID(); - string my_host = Kernel_Utils::GetHostname(); + CORBA::Object_var obj = ns->Resolve( "/Kernel/Session" ); + SALOME::Session_var session = SALOME::Session::_narrow( obj ) ; + if ( !session->_is_nil() ) + { + CORBA::String_var str_host = session->getHostname(); + CORBA::Long s_pid = session->getPID(); + string my_host = Kernel_Utils::GetHostname(); #ifdef WIN32 - long my_pid = (long)_getpid(); + long my_pid = (long)_getpid(); #else - long my_pid = (long) getpid(); + long my_pid = (long) getpid(); #endif - SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() ); + SetEmbeddedMode( s_pid == my_pid && my_host == str_host.in() ); + } } } } diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index fb16909b8..8e9007415 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -133,7 +133,8 @@ public: PortableServer::POA_ptr poa, PortableServer::ObjectId* contId, const char* instanceName, - const char* interfaceName ); + const char* interfaceName, + bool checkNS = true); // Destructor virtual ~SMESH_Gen_i(); diff --git a/src/SMESH_SWIG/CMakeLists.txt b/src/SMESH_SWIG/CMakeLists.txt index 240272cc6..4defb70f7 100644 --- a/src/SMESH_SWIG/CMakeLists.txt +++ b/src/SMESH_SWIG/CMakeLists.txt @@ -25,6 +25,7 @@ include_directories( ${PROJECT_SOURCE_DIR}/src/SMDS ${PROJECT_SOURCE_DIR}/src/SMESH ${PROJECT_SOURCE_DIR}/src/SMESH_I + ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/idl ) diff --git a/src/SMESH_SWIG/SMeshHelper.cxx b/src/SMESH_SWIG/SMeshHelper.cxx index 2c8d4bc5a..a9c10eadf 100644 --- a/src/SMESH_SWIG/SMeshHelper.cxx +++ b/src/SMESH_SWIG/SMeshHelper.cxx @@ -25,7 +25,7 @@ #include -std::string BuildSMESHInstance() +std::string BuildSMESHInstanceInternal(bool checkNS) { CORBA::ORB_var orb; { int argc(0); orb = CORBA::ORB_init(argc,nullptr); } @@ -42,7 +42,7 @@ std::string BuildSMESHInstance() // pman->activate(); // - SMESH_Gen_i *servant = new SMESH_Gen_i(orb,poa,const_cast(&conId.in()),"SMESH_inst_2","SMESH"); + SMESH_Gen_i *servant = new SMESH_Gen_i(orb,poa,const_cast(&conId.in()),"SMESH_inst_2","SMESH",checkNS); PortableServer::ObjectId *zeId = servant->getId(); CORBA::Object_var zeRef = poa->id_to_reference(*zeId); CORBA::String_var ior = orb->object_to_string(zeRef); diff --git a/src/SMESH_SWIG/SMeshHelper.h b/src/SMESH_SWIG/SMeshHelper.h index 391684db7..bef5532ca 100644 --- a/src/SMESH_SWIG/SMeshHelper.h +++ b/src/SMESH_SWIG/SMeshHelper.h @@ -17,6 +17,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#pragma once + #include -std::string BuildSMESHInstance(); +std::string BuildSMESHInstanceInternal(bool checkNS); diff --git a/src/SMESH_SWIG/SMeshHelper.i b/src/SMESH_SWIG/SMeshHelper.i index 51771ad1b..a3f599dc3 100644 --- a/src/SMESH_SWIG/SMeshHelper.i +++ b/src/SMESH_SWIG/SMeshHelper.i @@ -21,7 +21,14 @@ %include "std_string.i" +%{ +#include "SMeshHelper.h" +%} + %inline { - std::string BuildSMESHInstance(); + std::string BuildSMESHInstance() + { + return BuildSMESHInstanceInternal(false); + } } diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 045a46120..6ec2064ce 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -384,7 +384,8 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ): #print("==== smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc) #salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" ) import SMeshHelper - smesh_ior = SMeshHelper.BuildSMESHInstance() + checkNS = False + smesh_ior = SMeshHelper.BuildSMESHInstance(checkNS) import SMESH import CORBA orb=CORBA.ORB_init(['']) -- 2.39.2