Replace strict-aliasing UB in BSON double serialization#44975
Open
metsw24-max wants to merge 2 commits into
Open
Replace strict-aliasing UB in BSON double serialization#44975metsw24-max wants to merge 2 commits into
metsw24-max wants to merge 2 commits into
Conversation
|
Hi @metsw24-max, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
Signed-off-by: metsw24-max <metsw24@gmail.com>
71faaa8 to
a9fc07e
Compare
Mythra
reviewed
May 12, 2026
Member
Mythra
left a comment
There was a problem hiding this comment.
The actual code itself looks fine to me, though the CI system retriggers are interesting, have you been able to get tests passing locally @metsw24-max (i'll be running them locally myself here)? I'm just a bit surprised this PR has had force pushes/ci retriggers so often.
Contributor
|
See the warning in CI: |
Member
|
@metsw24-max Please fix the presubmit failure /wait |
b678556 to
2f0c6ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace reinterpret_cast-based type punning in
BufferHelper::writeDoublewith a standards-compliantstd::memcpybit copy.The previous implementation reinterpreted a double as an
int64_tthrough a pointer cast, which violates C++ strict-aliasing rules and may result in undefined behavior under compiler optimization.This change preserves the exact serialized bit pattern while removing UB from the BSON double serialization path. A static_assert was also added to verify size compatibility between double and int64_t.
Risk Level:
Low
Testing:
zero, signed zero, ±1, π, ±∞, NaN, denormals, and ±DBL_MAX
Docs Changes:
None