0022232: [CEA 837] Memory corruption in GEOM/SMESH that leads to segfault on debian64

Fix "Conditional jump or move depends on uninitialised value(s)" valgrind error
- initialize NETGENPlugin_NetgenLibWrapper::isComputeOk
This commit is contained in:
eap 2013-06-19 14:21:33 +00:00
parent c5e023e735
commit aabb991fa6
4 changed files with 24 additions and 30 deletions

View File

@ -2055,14 +2055,8 @@ namespace
bool NETGENPlugin_Mesher::Compute()
{
NETGENPlugin_NetgenLibWrapper aNgLib;
NETGENPlugin_NetgenLibWrapper ngLib;
// Internal method is needed to get result of computation
return aNgLib.isComputeOk = _compute( &aNgLib );
}
bool NETGENPlugin_Mesher::_compute( NETGENPlugin_NetgenLibWrapper* ngLib )
{
netgen::MeshingParameters& mparams = netgen::mparam;
MESSAGE("Compute with:\n"
" max size = " << mparams.maxh << "\n"
@ -2153,7 +2147,7 @@ bool NETGENPlugin_Mesher::_compute( NETGENPlugin_NetgenLibWrapper* ngLib )
err = 0; //- MESHCONST_ANALYSE isn't so important step
if ( !ngMesh )
return false;
ngLib->setMesh(( Ng_Mesh*) ngMesh );
ngLib.setMesh(( Ng_Mesh*) ngMesh );
ngMesh->ClearFaceDescriptors(); // we make descriptors our-self
@ -2637,6 +2631,8 @@ bool NETGENPlugin_Mesher::_compute( NETGENPlugin_NetgenLibWrapper* ngLib )
err = 0; // no fatal errors, only warnings
}
ngLib._isComputeOk = !err;
return !err;
}
@ -3469,9 +3465,12 @@ SMESH_Mesh& NETGENPlugin_Internals::getMesh() const
NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
{
Ng_Init();
myOutputFile = getOutputFileName();
netgen::mycout = new ofstream ( myOutputFile.c_str() );
cout << "NOTE: netgen output was redirected to file " << myOutputFile << endl;
_isComputeOk = false;
_outputFileName = getOutputFileName();
netgen::mycout = new ofstream ( _outputFileName.c_str() );
cout << "NOTE: netgen output was redirected to file " << _outputFileName << endl;
_ngMesh = Ng_NewMesh();
}
@ -3486,8 +3485,8 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
Ng_DeleteMesh( _ngMesh );
Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
if( isComputeOk )
RemoveOutputFile();
if( _isComputeOk )
removeOutputFile();
}
//================================================================================
@ -3529,12 +3528,12 @@ std::string NETGENPlugin_NetgenLibWrapper::getOutputFileName()
*/
//================================================================================
void NETGENPlugin_NetgenLibWrapper::RemoveOutputFile()
void NETGENPlugin_NetgenLibWrapper::removeOutputFile()
{
string tmpDir = SALOMEDS_Tool::GetDirFromPath( myOutputFile );
string tmpDir = SALOMEDS_Tool::GetDirFromPath( _outputFileName );
SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
aFiles->length(1);
std::string aFileName = SALOMEDS_Tool::GetNameFromPath( myOutputFile ) + ".out";
std::string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
aFiles[0] = aFileName.c_str();
if ( netgen::mycout)
{

View File

@ -48,7 +48,6 @@ class SMESH_Mesh;
class SMESH_Comment;
class SMESHDS_Mesh;
class TopoDS_Shape;
class TopTools_DataMapOfShapeShape;
class TopTools_IndexedMapOfShape;
class NETGENPlugin_Hypothesis;
class NETGENPlugin_SimpleHypothesis_2D;
@ -81,14 +80,17 @@ struct NETGENPlugin_ngMeshInfo
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
{
std::string myOutputFile;
bool isComputeOk;
bool _isComputeOk;
nglib::Ng_Mesh * _ngMesh;
NETGENPlugin_NetgenLibWrapper();
~NETGENPlugin_NetgenLibWrapper();
void setMesh( nglib::Ng_Mesh* mesh );
private:
std::string getOutputFileName();
void RemoveOutputFile();
void removeOutputFile();
std::string _outputFileName;
};
//=============================================================================
@ -169,7 +171,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
const std::string& pyFile); // debug
private:
bool _compute( NETGENPlugin_NetgenLibWrapper* ngLib );
SMESH_Mesh* _mesh;
const TopoDS_Shape& _shape;

View File

@ -180,10 +180,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh,
bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
#ifdef WITH_SMESH_CANCEL_COMPUTE
netgen::multithread.terminate = 0;
#endif
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::Compute()");
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
int faceID = meshDS->ShapeToIndex( aShape );
@ -294,10 +291,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
#ifdef WITH_SMESH_CANCEL_COMPUTE
if(netgen::multithread.terminate)
return false;
#endif
if ( err )
error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
}
@ -367,16 +362,15 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
}
}
ngLib._isComputeOk = !err;
return !err;
}
#ifdef WITH_SMESH_CANCEL_COMPUTE
void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute()
{
SMESH_Algo::CancelCompute();
netgen::multithread.terminate = 1;
}
#endif
//=============================================================================
/*!

View File

@ -325,7 +325,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
// Generate the volume mesh
// -------------------------
return compute( aMesh, helper, nodeVec, Netgen_mesh);
return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh));
}
//================================================================================
@ -564,7 +564,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
// Generate the volume mesh
// -------------------------
return compute( aMesh, *aHelper, nodeVec, Netgen_mesh);
return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, Netgen_mesh));
}
void NETGENPlugin_NETGEN_3D::CancelCompute()