Salome HOME
SIGSEGV at load time of _SMeshHelper.so
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Jan 2021 13:09:11 +0000 (14:09 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Jan 2021 13:09:11 +0000 (14:09 +0100)
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_SWIG/CMakeLists.txt
src/SMESH_SWIG/SMeshHelper.cxx
src/SMESH_SWIG/SMeshHelper.h
src/SMESH_SWIG/SMeshHelper.i
src/SMESH_SWIG/smeshBuilder.py

index ad5b17f8c8ab13a011653dd5d542c124d91aa610..4a8e9b303bde9c122584334685d459110554b33c 100644 (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() );
+      }
     }
   }
 }
index fb16909b89743ceb7c0822599a0afd0ef66409a9..8e90074150ddc60e5febca1f9699da7ac5bf766d 100644 (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();
 
index 240272cc68de785138bbc0a3233a4379e595a3ff..4defb70f76d2f996bc461717c9be226951bfcbe8 100644 (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
 )
 
index 2c8d4bc5ad8b9fae8281b7cba3b4cf797a1a7715..a9c10eadf08e07742383339564bf671bb272792f 100644 (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);
index 391684db778eb3b261cec35d45b9db10aee99090..bef5532ca3682633db1713fe908e25c2524937e9 100644 (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);
index 51771ad1b2a1dac09d587671908df82bc8f4cc56..a3f599dc33ef822dcba5a60c412e4643c04671fe 100644 (file)
 
 %include "std_string.i"
 
+%{
+#include "SMeshHelper.h"
+%}
+
 %inline
 {
-  std::string BuildSMESHInstance();
+  std::string BuildSMESHInstance()
+  {
+    return BuildSMESHInstanceInternal(false);
+  }
 }
index 045a4612008e6fbb6e68737a5b645776212e7e33..6ec2064ce29617c4cf8a3f993e0ff8ce1442eaab 100644 (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([''])