Message: Re: Segmentation fault after material re-use Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Segmentation fault after material re-use 

Forum: Geometry
Re: Question Segmentation fault after material re-use (Marek Szuba)
Date: 18 Oct, 2013
From: Marc Verderi <Marc Verderi>

Hi Marek,

     This looks "interesting" indeed...

     At this point, I would guess this is not much due to re-using a 
same material, which is perfectly legal, but I would suspect a nasty 
effect of the "inline const" method of the G4LogicalVolume GetMaterial() 
method, probably compiler related, and/or some confusion of the kernel 
because the world volume is being contructed, but not yet handled by the 
kernel (to which it is passed to, at the end of the Construct() method). 
In itself, your code is not wrong to me.

     I would suggest:
         - to fix (hopefully) your problem : start by having a 
"worldMaterial" pointer that you pass to all the volumes which should 
have this same material
         - you submit a but report. Please indicate your configuration 
(Geant4 version, OS, compiler, compiler version, etc...) at this might 
have relation to these. Please provide the stack trace as well.

Cheers,
Marc

On 10/18/2013 05:33 PM, Marek Szuba wrote:
> *** Discussion title: Geometry
>
> Hello,
>
> I have built very simple Geant4 geometry consisting of an aluminium box
> with mylar windows in two walls and filled, for the time being, the same
> material as the world volume. In the code it looks roughly like this:
>
> G4NistManager* nist = G4NistManager::Instance();
>
> /* World volume */
> G4Material* air = nist->FindOrBuildMaterial("G4_AIR");
> G4VSolid* worldSolid = new G4Box("World", 6*m, 2*m, 20*m);
> G4LogicalVolume* logicalWorld = new G4LogicalVolume(worldSolid, air, "World");
> new PVPlacement(NULL, G4ThreeVector(), logicalWorld, "World", NULL, false, 0, true);
>
> /* Box part 1 - solid aluminium */
> G4Material* boxWalls = nist->FindOrBuildMaterial("G4_Al");
> G4VSolid* boxSolid = new G4Box("Box", 270*cm, 49*cm, 180*cm);
> G4LogicalVolume* boxLV = new G4LogicalVolume(boxSolid, boxWalls, "Box");
> new PVPlacement(NULL, G4ThreeVector(0., 0., 300*cm), boxLV, "Box", logicalWorld, false, 0, true);
>
> /* Box part 2 - gaps in walls, same material as surroundings */
> G4VSolid* windowGapSolid = new G4Box("Box window gap", 270*cm - 1*cm, 49*cm - 1*cm, 1*mm);
> G4LogicalVolume* windowGapLV = new G4LogicalVolume(windowGapSolid, logicalWorld->GetMaterial(), "Box window gap");
> new PVPlacement(NULL, G4ThreeVector(0., 0., -(180*cm - 1*mm)), windowGapLV, "Box window gap upstream", boxLV, false, 0, true);
> new PVPlacement(NULL, G4ThreeVector(0., 0., +(180*cm - 1*mm)), windowGapLV, "Box window gap downstream", boxLV, false, 1, true);
>
> /* Box part 3 - gas inside it. At the moment the box is leaky i.e. is filled with same material as surroundings. */
> G4Material* gasInBox = logicalWorld->GetMaterial();
> G4VSolid* boxGasSolid = new G4Box("Box gas", 270*cm - 2*mm, 49*cm - 2*mm, 180*cm - 2*mm);
> G4LogicalVolume* boxGasLV = new G4LogicalVolume(boxGasSolid, gasInBox, "Box gas");
> new PVPlacement(NULL, G4ThreeVector(), boxGasLV, "Box gas", boxLV, false, 0, true);
>
> /* Box part 4 - mylar foil in windows */
> G4Material* mylar = nist->FindOrBuildMaterial("G4_MYLAR");
> G4VSolid* windowFoilSolid = new G4Box("Box window foil", 270*cm - 2*mm, 49*cm - 2*mm, 0.05*mm);
> G4LogicalVolume* windowFoilLV = new G4LogicalVolume(windowFoilSolid, mylar, "Box window foil");
> new PVPlacement(NULL, G4ThreeVector(0., 0., -(180*cm - 2*mm - 0.05*mm)), windowFoilLV, "Box window foil upstream", boxGasLV, false, 0, true);
> new PVPlacement(NULL, G4ThreeVector(0., 0., +(180*cm - 2*mm - 0.05*mm)), windowFoilLV, "Box window foil downstream", boxGasLV, false, 1, true);
>
> Now, if I stop detector construction after part 2 everything works fine
> even though I do re-use world material for window gaps. If however I
> include part 3 in the process, initialisation of Geant aborts with a
> segmentation fault and the following stack trace:
>
> [...snipped irrelevant bit...]
> #5
> #6  AddMaterial (aMaterial=0x7f5d00000005, this=0x25cc890) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:422
> #7  G4Region::ScanVolumeTree (this=this
> entry=0x25cc890, lv=0x3f88500, region=region
> entry=true) at /path/to/geant.9.6.p02/source/geometry/management/src/G4Region.cc:129
> #8  0x00007f5dee979c01 in G4Region::ScanVolumeTree (this=this
> entry=0x25cc890, lv=0x2e29000, region=region
> entry=true) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:215
> #9  0x00007f5dee97b4fe in G4Region::AddRootLogicalVolume (this=0x25cc890, lv=lv
> entry=0x2e29000) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:243
> #10 0x00007f5df14bab3a in G4RunManagerKernel::DefineWorldVolume (this=0x253c8e0, worldVol=, topologyIsChanged=topologyIsChanged
> entry=false) at /path/to/geant4.9.6.p02/source/run/src/G4RunManagerKernel.cc:220
> #11 0x00007f5df14b41b6 in G4RunManager::InitializeGeometry (this=0x253d000) at /path/to/geant4.9.6.p02/source/run/src/G4RunManager.cc:388
> #12 0x00007f5df14b3ed1 in G4RunManager::Initialize (this=0x253d000) at /path/to/geant4.9.6.p02/source/run/src/G4RunManager.cc:373
> [...snipped irrelevant bit...]
>
> The error also happens if I stop construction after creating boxGasLV -
> i.e. not only is there no foil in windows but even the gas volume itself
> doesn't get placed inside the box. To make things even more interesting,
> if instead of setting gasInBox to logicalWorld->GetMaterial() I invoke
> nist->FindOrBuildMaterial("G4_AIR") again, the error vanishes - only to
> appear again as a result of creation of windowFoilLV .
>
> Having spent the larger part of today going over my code both visually
> and with gdb, I had to eventually admit defeat and ask my question here.
> Thank you in advance for any hints which will help me fix this issue! If
> you need any more information, just let me know. All the best,
> --
> MS
> -------------------------------------------------------------
> Visit this GEANT4 at hypernews.slac.stanford.edu message (to reply or unsubscribe) at:
> http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/1302.html

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Segmentation fault after material re-use   (Marek Szuba - 05 Nov, 2013)
 Add Message Add Message
to: "Re: Segmentation fault after material re-use"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]