Skip to content

Commit d2b4f74

Browse files
committed
GPU TPC: Fix out of bounds after float arithmetic inaccuracy in track model decoding
1 parent 74fe0ad commit d2b4f74

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

GPU/GPUTracking/DataCompression/TPCClusterDecompressor.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ int TPCClusterDecompressor::decompress(const CompressedClusters* clustersCompres
4444
(&locks[0][0])[i].clear();
4545
}
4646
unsigned int offset = 0, lasti = 0;
47+
const unsigned int maxTime = (param.par.continuousMaxTimeBin + 1) * ClusterNative::scaleTimePacked - 1;
4748
GPUCA_OPENMP(parallel for firstprivate(offset, lasti))
4849
for (unsigned int i = 0; i < clustersCompressed->nTracks; i++) {
4950
while (lasti < i) {
@@ -89,6 +90,22 @@ int TPCClusterDecompressor::decompress(const CompressedClusters* clustersCompres
8990
time = timeTmp + ClusterNative::packTime(CAMath::Max(0.f, param.tpcGeometry.LinearZ2Time(slice, track.Z() + zOffset)));
9091
float tmpPad = CAMath::Max(0.f, CAMath::Min((float)param.tpcGeometry.NPads(GPUCA_ROW_COUNT - 1), param.tpcGeometry.LinearY2Pad(slice, row, track.Y())));
9192
pad = clustersCompressed->padResA[offset - i - 1] + ClusterNative::packPad(tmpPad);
93+
time = time & 0xFFFFFF;
94+
pad = (unsigned short)pad;
95+
if (pad >= param.tpcGeometry.NPads(row) * ClusterNative::scalePadPacked) {
96+
if ((signed short)pad >= (signed short)(-2 * ClusterNative::scalePadPacked)) {
97+
pad = 0;
98+
} else {
99+
pad = param.tpcGeometry.NPads(row) * ClusterNative::scalePadPacked - 1;
100+
}
101+
}
102+
if (param.par.continuousMaxTimeBin > 0 && time >= maxTime) {
103+
if (time >= 0xFFFFFF - 2 * ClusterNative::scaleTimePacked) {
104+
time = 0;
105+
} else {
106+
time = maxTime;
107+
}
108+
}
92109
} else {
93110
time = clustersCompressed->timeA[i];
94111
pad = clustersCompressed->padA[i];

0 commit comments

Comments
 (0)