Repository navigation
Fix timestamp96 decoding at zero seconds - #1190
Merged
redboltz merged 1 commit intoOct 8, 2026
Merged
Conversation
Treat zero seconds as nonnegative when converting the timestamp96 fraction to chrono durations. This keeps truncation consistent with timestamp64 and leaves negative-second handling unchanged. Add an explicit microsecond-resolution regression for both as and convert.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## cpp_master #1190 +/- ##
==============================================
- Coverage 85.36% 79.91% -5.46%
==============================================
Files 80 80
Lines 5099 5790 +691
Branches 507 629 +122
==============================================
+ Hits 4353 4627 +274
- Misses 746 1163 +417 🚀 New features to boost your workflow:
|
fhgffy
marked this pull request as ready for review
October 7, 2026 09:36
Contributor
|
@fhgffy , thank you for sending the PR. It looks good to me. |
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.
A timestamp96 value with seconds=0 and nanoseconds=500 currently decodes to 1 microsecond instead of 0 through both
asandconvert. With a seconds-resolution destination, it becomes 1 second. The equivalent timestamp64 representation correctly truncates to 0.The timestamp96 decoder sends
sec == 0through the negative-second adjustment. Change both conditions tosec >= 0, so nonnegative fractions use the same truncation direction as timestamp64. Negative-second behavior is unchanged.Add a regression with explicit timestamp96 bytes and a microsecond-resolution
time_point, covering both public conversion paths. Using an explicit duration avoids hiding the bug on hosts whose system clock has nanosecond precision.Fresh validation on Linux x86-64 with GCC 14.2.0 and Boost 1.85.0:
msgpack_cpp11andobject_with_zonetests with UBSan: 2/2 passedFocused test:
./build/test/msgpack_cpp11 --run_test=system_clock_96_zero_secondsFull C++20, non-Linux platforms, and out-of-range destination durations were not tested. Timestamp96 is a legal representation for these values under the timestamp specification, even when a serializer could choose a shorter format.