Problem 1991

Summary: G4IStore::GetImportance() crashes with null G4VPhysicalVolume
Product: Geant4 Reporter: mstoeckl
Component: geometry/biasingAssignee: alexander.howard
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 10.3   
Hardware: All   
OS: All   

Description mstoeckl 2017-07-11 23:42:16 CEST
The biasing process G4ImportanceBiasing can end up calling
G4IStore::GetImportance with a null physical volume; this 
causes a crash because one cannot add a null G4VPhysicalVolume
to the store.

G4ImportanceProcess::PostStepDoIt will call G4IStore::GetImportance
with a G4GeometryCell constructed from the pre/post point volumes
of a G4Step; and the G4SteppingManager uses a null volume
to signify a point being on the world boundary.

[The fix involving the least lines of code: default G4IStore::GetImportance
to 1./world volume importance when the volume is null. Alternatively,
test for a null volume in everything that might run after hitting the world boundary error messages, as they crash when trying to access properties 
of the null volume, for instance the G4IStore::GetImportance error message. 
Alternatively, constrain when the biasing is run to not happen
on exiting the world volume.]
Comment 1 alexander.howard 2023-11-21 16:40:05 CET
https://geant4-forum.web.cern.ch/t/g4istore-getimportance-crashes-with-null-g4vphysicalvolume/11132
Finds this problem manifested if a volume is placed outside of the world volume. Giving an anonymous segmentation fault is equally unhelpful, therefore a check should be introduced to throw a more controlled G4Exception instead. Will be added to the fix.
Comment 2 alexander.howard 2023-11-21 21:38:36 CET
I couldn't reproduce a crash for this, however, I can see the hazard of accessing the pointer to the PostStep volume, therefore I have returned no change if the next volume is null. Will be included in release v11.2.