-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[UBSAN]Fix runtime error for invalid bool value assignment #46907
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46907/42957 |
A new Pull Request was created by @smuzaffar for master. It involves the following packages:
@bbilin, @cmsbuild, @lviliani, @menglu21, @mkirsano can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
test parameters:
|
please test |
please test for CMSSW_15_0_UBSAN_X |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4303dc/43351/summary.html |
-1 Failed Tests: RelVals-INPUT
RelVals-INPUT
Comparison SummarySummary:
|
please test |
+1 Size: This PR adds an extra 16KB to repository Comparison SummarySummary:
|
please test lets refresh the tests @cms-sw/generators-l2 can you please review this? this just contains changes needed for code-format |
+1 Size: This PR adds an extra 16KB to repository Comparison SummarySummary:
|
+1 |
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 will now be reviewed by the release team before it's merged. @antoniovilela, @sextonkennedy, @rappoccio, @mandrenguyen (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
//std::swap(fTimeOffset, other.fTimeOffset); | ||
isVtxGenApplied_ = other.isVtxGenApplied_; | ||
isVtxBoostApplied_ = other.isVtxBoostApplied_; | ||
isPBoostApplied_ = other.isPBoostApplied_; |
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.
Sorry but strictly speaking this is not a correct implementation of swap()
, because the values from this
do not end up in other
(see https://en.cppreference.com/w/cpp/named_req/Swappable). I'm puzzled though why
cmssw/DataFormats/Common/interface/Wrapper.h
Lines 89 to 94 in 684a740
template <typename T> | |
Wrapper<T>::Wrapper(std::unique_ptr<T> ptr) : WrapperBase(), obj{construct_()}, present(ptr.get() != nullptr) { | |
if (present) { | |
obj = std::move(*ptr); | |
} | |
} |
ends up calling
swap()
.
Ah, it's because the move constructor and assignment are implemented with swap()
cmssw/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc
Lines 146 to 150 in 684a740
HepMCProduct::HepMCProduct(HepMCProduct&& other) : evt_(nullptr) { swap(other); } | |
HepMCProduct& HepMCProduct::operator=(HepMCProduct&& other) { | |
swap(other); | |
return *this; | |
} |
Maybe the real problem is that the move constructor does not initialize the bools?
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.
ah you are right @makortel . Let me revert this change and initialize bools in move constructor
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.
For UBSAN IBs, few workflows show runtime errors like [a]. Looks like this happens when we try to swap uninitialized bool values here e.g from https://github.com/cms-sw/cmssw/blob/master/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc#L149 . If I am not wrong, there is no need to use swap for boolean types, just assignment should be enough
Also removed using
fTimeOffset
comments[a]