cms-sw / cmssw

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

[UBSAN] TkDetLayers/src/TIBRing.cc warning: 'D.56128.closestIndex' may be used uninitialized #40925

Closed iarspider closed 1 year ago

iarspider commented 1 year ago
>> Building shared library tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/libRecoTrackerTkDetLayers.so
(...)
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.56128.closestIndex' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |                             ^
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.56128.nextIndex' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |                             ^
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  .../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.56128.nextDistance' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
.../src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |                             ^

Full log: link

iarspider commented 1 year ago

assign reconstruction

cmsbuild commented 1 year ago

New categories assigned: reconstruction

@mandrenguyen,@clacaputo you have been requested to review this Pull request/Issue and eventually sign? Thanks

cmsbuild commented 1 year ago

A new Issue was created by @iarspider .

@Dr15Jones, @perrotta, @dpiparo, @rappoccio, @makortel, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

aandvalenzuela commented 1 year ago

Hello @clacaputo, @mandrenguyen,

UBSAN IBs are broken for the time being, but this warning also appears at ASAN IBs:

>> Building shared library tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/libRecoTrackerTkDetLayers.so
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc11/external/gcc/11.2.1-f9b9dfdd886f71cd63f5538223d8f161/bin/c++ -O2 -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++17 -ftree-vectorize -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -msse3 -felide-constructors -fmessage-length=0 -Wall -Wno-non-template-friend -Wno-long-long -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-unused-parameter -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Werror=strict-aliasing -Werror=narrowing -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-psabi -fno-omit-frame-pointer -fsanitize=address -fsanitize=pointer-subtract -Ofast -fno-reciprocal-math -mrecip=none -Wno-error=unused-variable -DBOOST_DISABLE_ASSERTS -flto -fipa-icf -flto-odr-type-merging -fno-fat-lto-objects -Wodr -shared -Wl,-E -Wl,-z,defs tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/BladeShapeBuilderFromDet.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/CompatibleDetToGroupAdder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/CompositeTECPetal.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/CompositeTECWedge.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/DetGroupMerger.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/ForwardDiskSectorBuilderFromDet.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/ForwardDiskSectorBuilderFromWedges.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/GeometricSearchTracker.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/GeometricSearchTrackerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/GlobalDetRodRangeZPhi.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase1PixelBlade.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapLayerDoubleDisk.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapLayerDoubleDiskBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapRing.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapRingBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapSingleRing.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapSingleRingBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapSubDisk.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2EndcapSubDiskBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2OTBarrelLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2OTBarrelRod.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2OTBarrelRodBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/Phase2OTtiltedBarrelLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelBarrelLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelBlade.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelForwardLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelForwardLayerPhase1.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelRod.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/PixelRodBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/SimpleTECWedge.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TBLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TBPLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECPetal.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECPetalBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECWedge.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TECWedgeBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIBLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIBLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIBRing.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIBRingBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIDLayer.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIDLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIDRing.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TIDRingBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TOBLayerBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TOBRod.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TOBRodBuilder.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/TkDetUtil.cc.o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/modules.cc.o -o tmp/el8_amd64_gcc11/src/RecoTracker/TkDetLayers/src/RecoTrackerTkDetLayers/libRecoTrackerTkDetLayers.so -Wl,-E -Wl,--hash-style=gnu -L/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/biglib/el8_amd64_gcc11 -L/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/lib/el8_amd64_gcc11 -L/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/external/el8_amd64_gcc11/lib -L/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/static/el8_amd64_gcc11 -lRecoMTDDetLayers -lTrackingToolsDetLayers -lTrackingToolsGeomPropagators -lTrackingToolsTrajectoryState -lDataFormatsTrackReco -lDataFormatsTrackCandidate -lDataFormatsTrajectorySeed -lGeometryMTDGeometryBuilder -lDataFormatsTrackingRecHit -lGeometryMTDNumberingBuilder -lGeometryTrackerGeometryBuilder -lDataFormatsL1TrackTrigger -lDataFormatsTrackerCommon -lGeometryCommonTopologies -lCondFormatsAlignment -lDataFormatsBeamSpot -lDataFormatsGeometryCommonDetAlgo -lDataFormatsSiStripCluster -lGeometryTrackerNumberingBuilder -lTrackingToolsAnalyticalJacobians -lDataFormatsCandidate -lDataFormatsGeometrySurface -lDataFormatsTrajectoryState -lDetectorDescriptionCore -lDetectorDescriptionDDCMS -lGeometryMTDCommonData -lMagneticFieldEngine -lCondFormatsGeometryObjects -lDataFormatsCLHEP -lDataFormatsEcalDetId -lDataFormatsForwardDetId -lDataFormatsGeometryVector -lDataFormatsL1GlobalTrigger -lDataFormatsMuonDetId -lDataFormatsSiPixelDetId -lDataFormatsSiStripDetId -lFWCoreFramework -lDataFormatsDetId -lDataFormatsL1GlobalMuonTrigger -lDataFormatsMath -lDataFormatsPhase2TrackerDigi -lDataFormatsScouting -lDataFormatsSiPixelCluster -lDataFormatsSiStripDigi -lFWCoreCommon -lFWCoreServiceRegistry -lDataFormatsCommon -lFWCoreParameterSet -lFWCoreMessageLogger -lDataFormatsProvenance -lFWCorePluginManager -lFWCoreReflection -lTrackingToolsTrajectoryParametrization -lCondFormatsSerialization -lFWCoreConcurrency -lFWCoreUtilities -lFWCoreVersion -lUtilitiesBinningTools -lDDAlign -lDDCond -lDDCore -lDDParsers -lPhysics -lHist -lMatrix -lGenVector -lMathMore -lTree -lNet -lGeom -lThread -lMathCore -lRIO -lSmatrix -lboost_serialization -lCore -lboost_thread -lboost_date_time -lCLHEP -lpcre -lbz2 -lgsl -luuid -ltbb -lxerces-c -llzma -lz -lfmt -lcms-md5 -lopenblas -lcrypt -ldl -lrt -lstdc++fs -ltinyxml2
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.10484.closestIndex' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |                             ^
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.10484.nextIndex' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |                             ^
In member function 'computeCrossings',
    inlined from 'groupedCompatibleDetsV' at /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:115:31:
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: warning: 'D.10484.nextDistance' may be used uninitialized [-Wmaybe-uninitialized]
   210 |     return SubRingCrossings();
      |                             ^
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc: In member function 'groupedCompatibleDetsV':
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/90997b64a157d59561a5a770d5296d06/opt/cmssw/el8_amd64_gcc11/cms/cmssw/CMSSW_13_1_ASAN_X_2023-03-13-2300/src/RecoTracker/TkDetLayers/src/TIBRing.cc:210:29: note: '<anonymous>' declared here
  210 |     return SubRingCrossings();
      |

Find the compiler log at the following link. Thanks!

slava77 commented 1 year ago

@iarspider The log doesn't show where the use case of uninitialized value can happen. The coding design is to use isValid_ flag to check if the rest is meaningful. Is this warning just a case of "you have to initialize everything"? This comes at a cost and should not be required.

Also, this coding pattern repeats in TIDRing::computeCrossings, but doesn't appear in the build logs. Does the build stop on the first compile unit with warnings?

slava77 commented 1 year ago

type tracking

makortel commented 1 year ago

I had played last week a bit, and I was able to get rid of the warning by replacing the isValid_ flag with the use of std::optional. https://github.com/cms-sw/cmssw/pull/41164 shows how it looks. I did not do any performance evaluation.

iarspider commented 1 year ago

Fixed with #41164 .