Message: Clues why segmentation fault occurs using entries() for Hit Collection??? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Sad Clues why segmentation fault occurs using entries() for Hit Collection???  

Keywords: hit collection entries() method call segmentation fault
Forum: Event and Track Management
Date: 30 Sep, 2005
From: Blair Smith <bmsmith@lsu.edu>

I added some hit analysis code to my G4UserEventAction::EndOfEventAction() method, but now as soon as an event finishes and this method is invoked the application crashes due to a Segmentation fault.

From a backtrace the offending call seems to be when I try to get the number of hits in my main hit collection. The first few lines of the backtrace are as follows,

---
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 183037782496 (LWP 21250)]
0x0000002a9557f5e0 in G4THitsCollection<CZTEcrdHit>::entries (this=0x21)
    at /usr/local/apps/geant4/geant4.7.0.p01/include/G4THitsCollection.hh:103
103               = (std::vector<T*>*)theCollection;
(gdb) backtrace
#0  0x0000002a9557f5e0 in G4THitsCollection<CZTEcrdHit>::entries (this=0x21)
    at /usr/local/apps/geant4/geant4.7.0.p01/include/G4THitsCollection.hh:103
#1  0x0000002a955813e3 in CZTEventAction::EndOfEventAction (this=0x5f4890, evt=0x6bff60)
    at src/CZTEventAction.cc:203
#2  0x0000002a9b9f1b38 in G4EventManager::DoProcessing (this=0x5adc50, anEvent=0x6bff60)
    at src/G4EventManager.cc:252
#3  0x0000002a9b9f1e10 in G4EventManager::ProcessOneEvent (this=0x5adc50, anEvent=0x6bff60)
    at src/G4EventManager.cc:324
---

The code segment seemingly causing the problem is this bit (it crashes at the "... ecrdHC->entries();" line):

---
void CZTEventAction::EndOfEventAction(const G4Event* evt)
{
   G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
   CZTEcrdHitsCollection* ecrdHC = 0;

   if(HCE){
      //...
      ecrdHC = (CZTEcrdHitsCollection*)(HCE->GetHC(nEcrdHCID));
   }

   //...

   if( ecrdHC ){
      G4int n_hit = ecrdHC->entries();
      currEventTime = (*ecrdHC)[n_hit]->getHitTime();
      G4double ecrdEdep_total = 0.;
      //...
   }
---

I've removed some lines that I think are unimportant.

If anyone can help troubleshoot this problem for me then I'd be most greatful.

Thanks, Blair.

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

1 None: Re: Clues why segmentation fault occurs using entries() for Hit Collection???   (Tom Roberts - 30 Sep, 2005)
(_ None: Re: Clues why segmentation fault occurs using entries() for Hit Collection???   (Makoto Asai - 30 Sep, 2005)
 Add Message Add Message
to: "Clues why segmentation fault occurs using entries() for Hit Collection??? "

 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 ]