Problem 735 - giving NULL G4Material* to G4LogicalVolume silently crashes G4 during run initialization
Summary: giving NULL G4Material* to G4LogicalVolume silently crashes G4 during run ini...
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/management (show other problems)
Version: 7.0
Hardware: All All
: P2 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2005-03-29 17:56 CEST by jasondet
Modified: 2005-04-04 07:44 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description jasondet 2005-03-29 17:56:20 CEST
Dear Geant4 developers,

I have a G4 application in which I make a logical volume via a call like

myLVptr = new G4LogicalVolume(aSolid, G4Material::GetMaterial(matName), lvName);

Unfortunately, the string matName was not an existing G4Material, so
G4Material::GetMaterial(matName) quietly returned NULL. The G4LogicalVolume was
happy accepting this without any errors or warnings, but it eventually made my
program (silently) crash during G4RunManager::RunInitialization() when updating
the G4ProductionCutsTable.

I would like to suggest the following:

- Make G4LogicalVolume::SetMaterial(G4Material *pMaterial) check that pMaterial
is not NULL, and emit an error if it is. No logical volume should have a NULL
material pointer, right?

- Make G4Material::GetMaterial(G4String materialName) emit a warning message if
materialName is not the name of an existing material.

Thanks,
Jason
Comment 1 Michel.Maire 2005-03-30 11:22:59 CEST
done for what concern G4Material
Comment 2 Gabriele Cosmo 2005-04-04 07:44:59 CEST
NULL pointer to material must be allowed by G4LogicalVolume for the use-case of
readout and ghost (envelopes) geometries. The problem anyhow exists since NULL
material pointers should not be allowed for the 'tracking' geometry.
A fix has been introduced in G4Region and is included in the development tag
"geommng-V07-00-01". It will be included in future releases.
Thanks.