Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed array overflow by ignoring the out-of-bounds value ... #9527

Merged
merged 1 commit into from Jun 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Validation/EcalDigis/src/EcalSelectiveReadoutValidation.cc
Expand Up @@ -1378,7 +1378,13 @@ EcalSelectiveReadoutValidation::analyzeTP(edm::Event const & event,
double etSum = ttEtSums[iEta0][iPhi0];

int iE = meTp_->getTProfile()->FindFixBin(tpEt);
++tpEtCount[iE];
if ((iE >= 0) && (iE < 100)) {
++tpEtCount[iE];
} else {
// FindFixBin might return an overflow bin (outside tpEtCount range).
// To prevent a memory overflow / segfault, these values are ignored.
std::cout << "EcalSelectiveReadoutValidation: Invalid iE value: " << iE << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought, we shouldn't use std::cout. Shouldn't this be converted to message logger?

I see this is quite popular issue:

Begin processing the 88th record. Run 1, Event 7388, LumiSection 74 at 22-Jun-2015 15:37:19.177 CEST
EcalSelectiveReadoutValidation: Invalid iE value: 101
EcalSelectiveReadoutValidation: Invalid iE value: 101
EcalSelectiveReadoutValidation: Invalid iE value: 101
EcalSelectiveReadoutValidation: Invalid iE value: 101

@dmitrijus @deguio @Dr15Jones

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::cout is not allowed in code that is run in production.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've copied the std::cout code from a different location in the same file.
Point was to fix the error with least changes to the code and the code style.

I agree that we shouldn't use std::cout, but currently it's all over the code.
I will discuss it further and make a separate pull request(s) converting those.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. this one is has been merged anyway. :)

}

fill(meTpVsEtSum_, etSum, tpEt);
++TTFlagCount[it->ttFlag()];
Expand Down