| Summary: | GDML export shows Segmentation Fault in Multithreading, but runs fine in Sequential | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Sanchit Sharma <sanchitsharma> |
| Component: | persistency/gdml | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | RESOLVED FIXED | ||
| Severity: | major | ||
| Priority: | P4 | ||
| Version: | 10.5 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | Main file | ||
Thanks for reporting this. A protection has been now put to the internal Write() function of the GDML parser to prevent worker threads to execute writing and restrict this to only the master thread. The fix will be available in the next patch release. Respected Dr. Cosmo,
Greetings! I am not using the Write() function of the parser, but only Read().
My detector construction is below:
#include "DetectorConstruction.hh"
#include <G4LogicalVolume.hh>
#include <G4PVPlacement.hh>
#include <G4NistManager.hh>
#include <G4SystemOfUnits.hh>
#include <G4VisAttributes.hh>
#include <G4Box.hh>
#include <G4Tubs.hh>
#include <G4Orb.hh>
#include <G4SDManager.hh>
#include <G4RotationMatrix.hh>
#include <G4Transform3D.hh>
#include <G4SubtractionSolid.hh>
#include <G4Polyhedra.hh>
#include <G4Colour.hh>
#include <G4Material.hh>
#include <G4RunManager.hh>
#include <G4MultiFunctionalDetector.hh>
#include <G4PSEnergyDeposit.hh>
#include <G4SDManager.hh>
#include <G4SDParticleWithEnergyFilter.hh>
#include <G4PVParameterised.hh>
#include <G4LogicalVolume.hh>
#include <G4PVPlacement.hh>
#include <G4NistManager.hh>
#include <G4SystemOfUnits.hh>
#include <G4VisAttributes.hh>
#include <G4Box.hh>
#include <G4Orb.hh>
#include <G4SDManager.hh>
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
#include "G4GeometryTolerance.hh"
#include "G4GeometryManager.hh"
#include "G4UnionSolid.hh"
#include "G4GDMLParser.hh"
#include "G4PSEnergyDeposit.hh"
#include <G4TessellatedSolid.hh>
#include "G4UserLimits.hh"
using namespace std;
G4VPhysicalVolume* DetectorConstruction::Construct()
{
G4String GDMLsolid;
G4GDMLParser parser;
parser.Read("/homes/sanchitsharma/Geant4/X-D-MSND/CAD_RUNS/source/src/475.gdml");
G4VPhysicalVolume* world = parser.GetWorldVolume(); //world volume
return world;
}
void DetectorConstruction::ConstructSDandField()
{ G4GDMLParser parser;
parser.Read("/homes/sanchitsharma/Geant4/X-D-MSND/CAD_RUNS/source/src/475.gdml");
G4SDManager* SDman = G4SDManager::GetSDMpointer();
G4String fltName,particleName;
// Sensitive Detector Name
G4String phantomSDname = "BM";
//------------------------
// MultiFunctionalDetector
//------------------------
//
// Define MultiFunctionalDetector with name.
G4MultiFunctionalDetector* BM = new G4MultiFunctionalDetector(phantomSDname);
SDman->AddNewDetector( BM ); // Register SD to SDManager.
parser.GetVolume("fingdml")->SetSensitiveDetector(BM); // Assign SD to the logical volume.
G4String psName;
G4PSEnergyDeposit * scorer0 = new G4PSEnergyDeposit(psName="eDep");
G4SDParticleFilter* PFilter = new G4SDParticleFilter(fltName="PFilter");
PFilter->add(particleName="triton");
scorer0->SetFilter(PFilter);
BM->RegisterPrimitive(scorer0);
}
Hi Sanchit, the title of this ticket explicitly refers to "GDML export"... I have verified that "importing" (i.e. reading) GDML descriptions does not reproduce thread contention or crashes, as this operation should be only executed while defining the geometry in either your main() at the beginning, or inside your Construct() method, where everything is operated by the master thread. The code you attached shows an issue though, i.e. you are repeating the GDML import within ConstructSDandField(). Why?? This may explain the crash. |
Created attachment 558 [details] Main file Hello, I have made a GDML file to export in Geant4. The code works fine when I compile and run in Sequential mode of Geant4(compiled without multithreading). But when I try to run this on Geant4 with multithreading. It gives me a Segmentation Fault. My Main file is attached along with this mail. Thanks!