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

HBHE M2 = fix Memory Leak #17821

Merged
merged 3 commits into from Mar 10, 2017
Merged

Conversation

mariadalfonso
Copy link
Contributor

@mariadalfonso mariadalfonso commented Mar 8, 2017

No changes are expected at relVal level

@igv4321 @kpedro88 : please check

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

A new Pull Request was created by @mariadalfonso for master.

It involves the following packages:

RecoLocalCalo/HcalRecAlgos

@perrotta, @cmsbuild, @slava77, @davidlange6 can you please review it and eventually sign? Thanks.
@argiro this is something you requested to watch as well.
@Muzaffar, @davidlange6, @smuzaffar you are the release manager for this.

cms-bot commands are listed here #13028


// initialize for every different channel types (HPD vs SiPM)

if (!(&ps == currentPulseShape_ && isHPD == isCurrentChannelHPD_))
Copy link
Contributor

Choose a reason for hiding this comment

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

Both "currentPulseShape_" and "isCurrentChannelHPD_" are used uninitialized here

@igv4321
Copy link
Contributor

igv4321 commented Mar 8, 2017

Maria, please initialize currentPulseShape_ in the constructor to nullptr.

You also do need to fix the memory leak. Replace the line
spfunctor_ = new ROOT::Math::Functor(...);
with
delete spfunctor_; spfunctor_ = new ROOT::Math::Functor(...);
The same for dpfunctor_ and tpfunctor_.

@mariadalfonso
Copy link
Contributor Author

@igv4321 , fixed as you suggested, is ok now ?

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

Pull request #17821 was updated. @perrotta, @cmsbuild, @slava77, @davidlange6 can you please check and sign again.

@igv4321
Copy link
Contributor

igv4321 commented Mar 8, 2017

This will work

@slava77
Copy link
Contributor

slava77 commented Mar 8, 2017

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/18250/console Started: 2017/03/08 17:50

spfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3);
dpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::doublePulseShapeFunc, 5);
tpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::triplePulseShapeFunc, 7);
delete spfunctor_; spfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you changed *functor_ to be std::unique_ptr<ROOT::Math::Functor> this would automatically handle deleting both here and in the destructor.

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 8, 2017

spfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3);
dpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::doublePulseShapeFunc, 5);
tpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::triplePulseShapeFunc, 7);
spfunctor_ = std::unique_ptr<ROOT::Math::Functor>( new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3) );
Copy link
Contributor

Choose a reason for hiding this comment

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

If you like, you could save yourself some typing by doing

spfunctor_ = std::make_unique<ROOT::Math::Functor>(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3);

@Dr15Jones
Copy link
Contributor

The move to std::unique_ptr looks good to me. The use of std::make_unique is only a suggestion.

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 9, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 9, 2017

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 9, 2017

@perrotta
Copy link
Contributor

perrotta commented Mar 9, 2017

Still "isCurrentChannelHPD_" is used uninitialized at line (now) 280 of PulseShapeFitOOTPileupCorrection.cc

@igv4321
Copy link
Contributor

igv4321 commented Mar 9, 2017

It is initialized on line 285. Good enough because in the expression A && B, B is never executed if A is false, and on the first comparison &ps == currentPulseShape_ is false (ps is a reference, so &ps is not a null pointer).

@slava77
Copy link
Contributor

slava77 commented Mar 9, 2017

@mariadalfonso @igv4321
please add a link or attach a valgrind report just to see what else is there

@igv4321
Copy link
Contributor

igv4321 commented Mar 9, 2017

You are welcome to take a look at /uscms_data/d3/pedrok/hf/reco/CMSSW_8_4_0/src/10024.0_TTbar_13+TTbar_13TeV_TuneCUETP8M1_2017_GenSimFull+DigiFull_2017+RecoFull_2017+ALCAFull_2017+HARVESTFull_2017/log_valgrind1.log

@perrotta
Copy link
Contributor

perrotta commented Mar 9, 2017

Thank you @igv4321 : could you please copy the valgrind report on afs, or somewhere else publicly accessible?

@kpedro88
Copy link
Contributor

kpedro88 commented Mar 9, 2017

@perrotta: /afs/cern.ch/user/p/pedrok/public/log_valgrind1.log

@Dr15Jones
Copy link
Contributor

The valgrind log pointed to this problem as well: #17861

@slava77
Copy link
Contributor

slava77 commented Mar 9, 2017 via email

@perrotta
Copy link
Contributor

+1
Memory leak is cured, as intended.
No regression expected, no regression observed.

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @Muzaffar, @davidlange6, @smuzaffar

@davidlange6
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 2780cc2 into cms-sw:master Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants