Skip to content

Undefined behaviour sanitizer error for PrVeloUT

The following discussion from !2065 (merged) should be addressed:

  • @jonrob started a discussion: (+1 comment)

    @decianm I'm afraid there is another sanitiser error that I missed, my apologies. Take a look for instance at the brunel-upgrade-baseline test at

    https://lhcb-nightlies.web.cern.ch/logs/tests/nightly/lhcb-sanitizers/589/x86_64-centos7-gcc9-dbg+ubsan/Brunel/

    /workspace/build/Rec/Pr/PrVeloUT/src/PrVeloUT.cpp:593:43: runtime error: signed integer overflow: -2147483647 * -2147483647 cannot be represented in type 'int'
        #0 0x7fa2335ab16c in LHCb::Pr::VeloUT::findAllSectors(std::array<LHCb::Pr::ExtrapolatedStates, 4ul> const&, LHCb::Pr::MiniStatesArray&, LHCb::UTDAQ::GeomCache const&) const /workspace/build/Rec/Pr/PrVeloUT/src/PrVeloUT.cpp:593

    caused by

    const int maxCols = std::min( ( subcolmax - subcolmin ).hmax( gathermask ) + 1, 3 );
    const int maxRows = std::min( ( subrowmax - subrowmin ).hmax( gathermask ) + 1, 3 );
    
    maxColsRows[layerIndex] = maxCols * maxRows;

    It seems a bit fishy that maxCols and maxRows have large negative values, which then leads to the overflow when multiplying them together ?

    Could you please take a look, and submit a fix for it in a follow up MR, thanks.

Edited by Christopher Rob Jones