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
Pr81x l1t memory fixes #16088
Conversation
…r, (2) release memory from parser back to system at the end of 'read' methods.
… in L1TMuonBarrelParamsHelper.
A new Pull Request was created by @rekovic for CMSSW_8_1_X. It involves the following packages: L1Trigger/L1TMuonBarrel @cmsbuild, @rekovic, @mulhearn, @davidlange6 can you please review it and eventually sign? Thanks. cms-bot commands are list here #13028 |
please test |
The tests are being triggered in jenkins. |
+1 |
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); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
+1 |
The tests are being triggered in jenkins. |
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 |
+1 |
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 The eventually copied XmlConfigReader and the original one held by the ESProducer both share the same pointer to One should never write a destructor without also writing (or doing 'delete') a copy constructor and an |
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. |
This is 81x version of #16085, except for this part which is already in 81x.
(free allocated memory before every return). This is already provided in 81x Fix memory leak in L1Trigger/L1TMuonBarrel/src/L1MuBMEUX #16061 by @davidlange6
This PR contains 2 types of fixes concerning memory management by L1Trigger: