From ffdea773fff2fa13ea576e76213d92d553bac26a Mon Sep 17 00:00:00 2001 From: Oz Amram Date: Tue, 14 Sep 2021 14:39:26 -0500 Subject: [PATCH 1/3] copy_to_buffer return right away if range empty --- .../SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc index 26b9a64ea3a52..433eefe720030 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc @@ -222,6 +222,11 @@ void PixelThresholdClusterizer::copy_to_buffer(DigiIterator begin, DigiIterator // std::cout << (doMissCalibrate ? "VI from db" : "VI linear") << std::endl; } #endif + + //avoid undefined behavior + if (end <= begin) + return; + int electron[end - begin]; // pixel charge in electrons memset(electron, 0, (end - begin) * sizeof(int)); From f8f2afc821bfba3dc0d2f5cee4ff7845beec7e7a Mon Sep 17 00:00:00 2001 From: Oz Amram Date: Mon, 20 Sep 2021 10:10:56 -0500 Subject: [PATCH 2/3] Check range before calling copy_to_buffer, add LogWarning --- .../plugins/PixelThresholdClusterizer.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc index 433eefe720030..e1ba455a249ac 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc @@ -148,7 +148,8 @@ void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input, // Copy PixelDigis to the buffer array; select the seed pixels // on the way, and store them in theSeeds. - copy_to_buffer(begin, end); + if (end > begin) + copy_to_buffer(begin, end); assert(output.empty()); // Loop over all seeds. TO DO: wouldn't using iterators be faster? @@ -223,9 +224,11 @@ void PixelThresholdClusterizer::copy_to_buffer(DigiIterator begin, DigiIterator } #endif - //avoid undefined behavior - if (end <= begin) + //If called with empty / invalid DetSet, warn the user + if (end <= begin) { + edm::LogWarning("PixelThresholdClusterizer") << " copy_to_buffer called with empty or invalid range" << std::endl; return; + } int electron[end - begin]; // pixel charge in electrons memset(electron, 0, (end - begin) * sizeof(int)); From 866cfe791c3256b9f6354523dd9ff43620c631fa Mon Sep 17 00:00:00 2001 From: Malik Shahzad Muzaffar Date: Tue, 28 Sep 2021 08:08:37 +0200 Subject: [PATCH 3/3] force dummy commit to change the commit as bot has reached max commit status for this --- .../SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc index e1ba455a249ac..5aac76529ab0a 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc @@ -224,7 +224,7 @@ void PixelThresholdClusterizer::copy_to_buffer(DigiIterator begin, DigiIterator } #endif - //If called with empty / invalid DetSet, warn the user + //If called with empty/invalid DetSet, warn the user if (end <= begin) { edm::LogWarning("PixelThresholdClusterizer") << " copy_to_buffer called with empty or invalid range" << std::endl; return;