cms-sw / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
1.09k stars 4.33k forks source link

[UBSAN][Align]Runtime error where there is no globalDerivativesCalibration #46726

Open smuzaffar opened 3 days ago

smuzaffar commented 3 days ago

For UBSAN IBs, we see runtime errors like [a]. This happens when we call https://github.com/cms-sw/cmssw/blob/master/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc#L793 with empty theIntBuffer, theFloatBufferX, theFloatBufferY. Error goes away if we set ignoreHitsWithoutGlobalDerivatives to true.

@cms-sw/alca-l2 , can you please look in to this?

[a] https://cmssdt.cern.ch/SDT/cgi-bin/logreader/el8_amd64_gcc12/CMSSW_14_2_UBSAN_X_2024-11-15-2300/pyRelValMatrixLogs/run/1001.0_RunMinBias2011A/step3_RunMinBias2011A.log#/100-100

/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/stl_vector.h:1124:34: runtime error: reference binding to null pointer of type 'value_type'

    #0 0x148ef8da42ec in std::vector<float, std::allocator<float> >::operator[](unsigned long) /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/stl_vector.h:1124
    #1 0x148ef8da42ec in MillePedeAlignmentAlgorithm::callMille2D(ReferenceCountingPointer<ReferenceTrajectoryBase> const&, unsigned int, std::vector<int, std::allocator<int> > const&, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&) src/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc:1466
    #2 0x148ef8da7e75 in MillePedeAlignmentAlgorithm::callMille(ReferenceCountingPointer<ReferenceTrajectoryBase> const&, unsigned int, std::vector<int, std::allocator<int> > const&, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&) src/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc:1366
    #3 0x148ef8db3142 in MillePedeAlignmentAlgorithm::addMeasurementData(edm::EventSetup const&, AlignmentAlgorithmBase::EventInfo const&, ReferenceCountingPointer<ReferenceTrajectoryBase> const&, unsigned int, AlignmentParameters*&) src/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc:793
    #4 0x148ef8dcfc4a in MillePedeAlignmentAlgorithm::addReferenceTrajectory(edm::EventSetup const&, AlignmentAlgorithmBase::EventInfo const&, ReferenceCountingPointer<ReferenceTrajectoryBase> const&) src/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc:574
smuzaffar commented 3 days ago

assign alca

cmsbuild commented 3 days ago

New categories assigned: alca

@atpathak,@consuegs,@perrotta you have been requested to review this Pull request/Issue and eventually sign? Thanks

cmsbuild commented 3 days ago

cms-bot internal usage

cmsbuild commented 3 days ago

A new Issue was created by @smuzaffar.

@Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

smuzaffar commented 3 days ago

Note the runtime error occurs when we try to get the address of first element of zero size vector float *newGlobDerivsX = &(newGlobDerivs[0]);

perrotta commented 2 days ago

@mmusich (since you were the last one who interacted with that MillePedeAlignmentAlgorithm.cc file in github): is there any reason not to set ignoreHitsWithoutGlobalDerivatives as true by default? As correctly written at L1393 "&(localDerivatives[0]) etc. are valid - as long as vector is not empty" and it is wrong trying to enter those methods if theFloatBufferX.empty() at L788

mmusich commented 2 days ago

(since you were the last one who interacted with that MillePedeAlignmentAlgorithm.cc file in github)

@perrotta please refer to Tracker DPG.

perrotta commented 2 days ago

@cms-sw/trk-dpg-l2 (repeating what above): is there any reason not to set ignoreHitsWithoutGlobalDerivatives as true by default? As correctly written at L1393 "&(localDerivatives[0]) etc. are valid - as long as vector is not empty" and it is wrong trying to enter those methods if theFloatBufferX.empty() at L788