Gate icon indicating copy to clipboard operation
Gate copied to clipboard

segmentation fault when using SinglesDigitizer and ROOT output

Open bl0x opened this issue 1 year ago • 1 comments

I see a segfault when using a SinglesDigitizer together with ROOT output:

/usr/include/c++/13.2.1/bits/stl_vector.h:1125: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = GateHitTree*; _Alloc = std::allocator<GateHitTree*>; reference = GateHitTree*&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

This originates from accessing the first element of m_treesHit in GateToRoot::RecordEndOfAcquisition(). However, m_treesHit is cleared in GateToRoot::RecordEndOfRun(), so the access fails and produces a segfault.

Perhaps clearing m_treesHit at the end of a run is not good in this case:

https://github.com/OpenGATE/Gate/blob/a1f0a36ab9d46a1396d718f0506497ddf42de498/source/digits_hits/src/GateToRoot.cc#L682

I am not sure about the sequence of which methods get called when, but I am reckoning that

RecordBeginOfAcquisiton() and RecordEndOfAcquisition()

are called on a greater scope compared to the

RecordBeginOfRun() and RecordEndOfRun()

methods.


This would imply, that when RecordEndOfAcquisition() is called, m_treesHit has been cleared from the last invocation of RecordEndOfRun().

Perhaps it is better to call m_treesHit.clear() right before the container is filled in RecordBeginOfRun().

bl0x avatar Nov 29 '23 00:11 bl0x

Dear Bastien,

Indeed I need to fix it! Could you, please, share your macros that I could reproduce the seg fault? (possible by email : kochebina at gmail dot com)

For the sequence it is: RecordBeginOfAcquisiton() RecordBeginOfRun() RecordBeginOfEvent() RecordBeginOfEvent() RecordEndOfRun() RecordEndOfAcquisition()

I started to clear m_treesHit in RecordEndOfRun() for the case when one wants to simulate several runs un the same aquisition. I'll check what to do with that

Cheers, Olga

kochebina avatar Dec 08 '23 13:12 kochebina