Problem 2515 - G4NumIntTwoBodyAngDst bug in std::fill call in ctor -- wrong dimension used
Summary: G4NumIntTwoBodyAngDst bug in std::fill call in ctor -- wrong dimension used
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/hadronic/models/cascade (show other problems)
Version: 11.0
Hardware: All All
: P4 normal
Assignee: Alberto.Ribon
URL:
Depends on:
Blocks:
 
Reported: 2022-11-09 09:10 CET by Sven Menke
Modified: 2022-11-14 11:31 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Sven Menke 2022-11-09 09:10:27 CET
Dear Dennis, Mike, all,

there is a bug in line 54 of source/processes/hadronic/models/cascade/cascade/include/G4NumIntTwoBodyAngDst.hh
The std::fill call uses the offset nDists to the pointer angDist for setting the workspace initially to 0's. angDist has dimension nAngles not nDists! 
As far as I can tell currently nDists is always smaller than nAngles (I see nDists of 11 or 15 while nAngles seems to be always 19). So in practice it means that the last few angular bins are not initialized to 0 ... 
More severe would be if someone instantiates this class with nDists > nAngles. Then you'd get a segv.

The fix is easy. Please replace line 54 with:

    std::fill(angDist, angDist+nAngles, 0.);     // Initialize working buffer

Thanks,
--Sven
Comment 1 Alberto.Ribon 2022-11-14 11:31:37 CET
Dear Sven,

thank you very much for the suggestion, which has been already integrated in our repository!

Cheers,
Alberto