| Summary: | uninitialized variable in G4SteppingManager::SetInitialStep(...) | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Tom Roberts <tjrob> |
| Component: | tracking | Assignee: | Takashi.Sasaki |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P5 | ||
| Version: | 9.1 | ||
| Hardware: | All | ||
| OS: | All | ||
I am very sorry, but I do not understand what you want to do and what is your problem. Could write more detail about your problem? This is purely a C++ issue -- G4SteppingManager::SetInitialStep(...) must initialize fTouchableHandle for the current track, and there is a possible path through the code in which it is not initialized. This has not been noticed before because it is quite rare to follow this path, but I now have code which does so (it crashes because of the uninitialized variable).
In my local copy of the code I fixed it this way (just after line 309):
fTouchableHandle = fTrack->GetTouchableHandle();
and this solved my problem. But I don't know enough about the behavior of the code, and it's possible that it should be:
fTouchableHandle = fNavigator->CreateTouchableHistory()
(I base this on the way the surrounding code looks.) In particular, it is possible that my fix uses the wrong touchable handle. In my case, possibly having the wrong touchable handle does not seem to be a problem, but in general that might not be true, so someone who understand the details of this code should look at it. In any case, SOME initialization of fTouchableHandle with a valid touchable handle is needed inside that }else{ at line 309. Note that the code is setting the track touchable handle BEFORE resetting the navigator, which might well be incorrect. It should be looked at in detail by someone who understands what is happening (i.e. how the navigator, track, and touchable handle are inter-related).
Thank you very much for reporting the problem. I have fixed the code and committed on CVS. |
This is Geant4.9.1.p01. In G4SteppingManager::SetInitialStep(...) it is possible to leave fTouchableHandle uninitialized. In virtually all cases the code does not follow this pathway, so it works. But I have problems with it when starting to track a secondary. In G4SteppingManager.cc, just before line 310, add fTouchableHandle = fTrack->GetTouchableHandle(); This is right after the }else{ from an if testing fTrack->GetTouchableHandle(). Note: it is possible that this should use fNavigator->CreateTouchableHistory() instead, I'm not sure. The code in this }else{ looks strange, as it is setting the track touchable handle BEFORE resetting the navigator. Perhaps it should bbe re-visited.