Skip to content

InDetLowBetaFinder: Protect against out-of-bounds array access.

An out-of-bounds array access was flagged by ubsan in TrtToolBetaLiklihood when running in the debug build.

This was seen in the third event while trying to reproduce ATR-21791:

/build/atnight/localbuilds/nightlies/master/athena/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/TrtToolsBetaLiklihood.cxx:339:69: runtime error: index 44 out of bounds for type 'double [24]'
/build/atnight/localbuilds/nightlies/master/athena/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/TrtToolsBetaLiklihood.cxx:339:128: runtime error: index 45 out of bounds for type 'double [24]'

The problem was at this line:

         prob = remain*LBitProb[idx1][EtaBin][becIdx][bit-binShift-1] + (1.-remain)*LBitProb[idx1][EtaBin][becIdx][bit-binShift];

The last array has size 24, but here bit==19, binShift==-26, so bit-binShift == 45. Also, tShift==-25.218409847322423, nominalDrift==4.53986979, and estDriftA[i]==95.2978058 (i=4).

Added an additional test to treat bin-binShift >= 24 the same way that the code currently treats bin-binShift-1 < 0.

Merge request reports