Skip to content

Use ushort instead of short for UT hit indices to avoid overflow crashes in UT-related algorithms

The UT hit index was previously stored as a signed short, limiting the maximum number of hits to 32767, with -1 used as the invalid index value.

In high-occupancy events, the number of UT hits per event can exceed this limit, leading to overflow behavior. In particular, static_cast<short>(int) can return a negative value, which caused a segmentation fault when the algorithm attempted to access memory using a negative index.

In this MR, we replace short with unsigned short for UT hit indices, extending the valid range to 65534 and using 65535 as the invalid index value. Since static_cast<unsigned short>(int) always returns a positive value, even if overflow occurs, it will not cause any crashes in HLT1, though the algorithm output may become unreliable.

This MR is required for the 2025 ion runs.

TODO: UT related algorithms

  • CompassUT: changes completed
  • Matching with UT: no changes needed, it already uses unsigned short
  • Downstream tracking: changes completed

FYI: @dtou @oboenteg @sbelin @thboettc @msaur @tmombach @mveghel @samarian

Merge request reports

Loading