SIGSEGV at load time of _SMeshHelper.so

This commit is contained in:
Anthony Geay 2021-01-13 14:09:11 +01:00
parent 8a20cf2905
commit f3b3cfd765
7 changed files with 33 additions and 17 deletions

View File

@ -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() );
}
}
}
}

View File

@ -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();

View File

@ -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
)

View File

@ -25,7 +25,7 @@
#include <cstring>
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<PortableServer::ObjectId*>(&conId.in()),"SMESH_inst_2","SMESH");
SMESH_Gen_i *servant = new SMESH_Gen_i(orb,poa,const_cast<PortableServer::ObjectId*>(&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);

View File

@ -17,6 +17,8 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#pragma once
#include <string>
std::string BuildSMESHInstance();
std::string BuildSMESHInstanceInternal(bool checkNS);

View File

@ -21,7 +21,14 @@
%include "std_string.i"
%{
#include "SMeshHelper.h"
%}
%inline
{
std::string BuildSMESHInstance();
std::string BuildSMESHInstance()
{
return BuildSMESHInstanceInternal(false);
}
}

View File

@ -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([''])