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

Pr81x l1t memory fixes #16088

Merged

Conversation

rekovic
Copy link
Contributor

@rekovic rekovic commented Oct 4, 2016

This is 81x version of #16085, except for this part which is already in 81x.

This PR contains 2 types of fixes concerning memory management by L1Trigger:

  • fix for repetitive memory allocation in Muon Overlap XML Parser to reset DOM vector pool and release all the associated memory back to the system before re-using read methods.
  • fix for Invalid writes in Muon Barell ParamsHelper class by reserving the correct vector size.

…r, (2) release memory from parser back to system at the end of 'read' methods.
@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2016

A new Pull Request was created by @rekovic for CMSSW_8_1_X.

It involves the following packages:

L1Trigger/L1TMuonBarrel
L1Trigger/L1TMuonOverlap

@cmsbuild, @rekovic, @mulhearn, @davidlange6 can you please review it and eventually sign? Thanks.
@Martin-Grunewald this is something you requested to watch as well.
@slava77, @smuzaffar you are the release manager for this.

cms-bot commands are list here #13028

@rekovic
Copy link
Contributor Author

rekovic commented Oct 4, 2016

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/15519/console

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2016

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2016

@rekovic
Copy link
Contributor Author

rekovic commented Oct 4, 2016

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2016

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

@@ -36,7 +36,7 @@ void L1TMuonBarrelParamsHelper::configFromPy(std::map<std::string, int>& allInts
setAssLUTPath(AssLUTpath);
///Read Pt assignment Luts
std::vector<LUT> pta_lut(0); pta_lut.reserve(19);
std::vector<int> pta_threshold(6); pta_threshold.reserve(9);
std::vector<int> pta_threshold(6); pta_threshold.reserve(10);
Copy link
Contributor

Choose a reason for hiding this comment

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

@rekovic - maybe you mean resize? reserve doesn't do too much here...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it should be resiz, or better just declare with the correct size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidlange6 No, I meant reserve, as it was originally used by the developer, as the intended estimate of the capacity of the vector is known = 10.
This would only allocate memory, but leave vector elements uninitialized. They are filled
later on in the loop. But I guess either one reserve() and resize() would work.

In any case, there were no more "Invalid writes" from BMTF as originally reported by valgrind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ Yes, declaring vector initially with the correct size should also work. If preferred can make this change. Please advise.

Copy link
Contributor

Choose a reason for hiding this comment

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

that is not quite what reserve does - if you want a vector with 10 elements, you want resize(10) or better just std::vector pta_threshold(10) - otherwise you are relying on luck that push_back or reserve (etc etc) are never called on this vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Changed now to declare vector with the correct size initially.

@rekovic
Copy link
Contributor Author

rekovic commented Oct 6, 2016

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/15561/console

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

This pull request is fully signed and it will be integrated in one of the next CMSSW_8_1_X IBs after it passes the integration tests. This pull request requires discussion in the ORP meeting before it's merged. @slava77, @davidlange6, @smuzaffar

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 6, 2016

@davidlange6
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 5cbbe32 into cms-sw:CMSSW_8_1_X Oct 6, 2016
@Dr15Jones
Copy link
Contributor

The crash is becuase the XmlConfigReader declares a destructor but no copy-constructor. The XmlConfigReader is held by value as a member data to TrigSystem, which is held by value as member data to L1TMuonBarrelParamsHelper which in turn is copied here
https://github.com/cms-l1t-offline/cmssw/blob/8a75953b6f0cdc8a12fc7a5f8e85718c180ba548/L1Trigger/L1TMuonBarrel/plugins/L1TMuonBarrelParamsESProducer.cc#L705

The eventually copied XmlConfigReader and the original one held by the ESProducer both share the same pointer to parser_. The copy in the EventSetup gets deleted first so deletes parser_. Then the one in the ESProducer gets delete, which does a double delete and crashes the program.

One should never write a destructor without also writing (or doing 'delete') a copy constructor and an operator=.

@rekovic
Copy link
Contributor Author

rekovic commented Oct 10, 2016

Hi @Dr15Jones, I agree, the Rule of Three should always be followed.

However, it is a very strange thing that this crash reported in Barrel Muon ESProducer which uses "XmlConfigReader" from L1TCommon did not exist prior to the changes in the this PR. This PR had changes in the "XMLConfigProducer" from L1TMuonOverlap. Note that these are two different ConfigProducers - different names - XML vs Xml. In this PR a destructor to "XMLConfigProducer" was introduced, which also has a a call to XMLPlatformUtils::Terminate();.

According to this, having multiple calls to XMLPlatformUtils::Initilize() and XMLPlatformUtils::Terminate(), should not be a problem.

However, removing of XMLPlatformUtils::Terminate(); mitigates the crash, #16159.
Maybe @ianna can comment here.

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

4 participants