MDEV-39744: Assertion buf != end failed in decimal_mul#5265
Open
raghunandanbhat wants to merge 1 commit into
Open
MDEV-39744: Assertion buf != end failed in decimal_mul#5265raghunandanbhat wants to merge 1 commit into
buf != end failed in decimal_mul#5265raghunandanbhat wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request fixes an assertion failure buf != end in decimal_mul by replacing the assertion and loop with a safe boundary check (buf < end). It also adds test cases to verify the fix. The reviewer suggests removing a redundant and fragile fuzzer-generated query containing LOCALTIME from the test suite, as the other deterministic queries are sufficient to cover the bug.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
9105370 to
fd21ecb
Compare
1a16cbf to
66325cf
Compare
Problem: With `div_precision_increment=0`, a division whose quotient rounds away to zero (e.g. -299/450) produced a decimal with no digit words (intg=0 and frac=0) while still keeping the sign bit set. That is a malformed value. Multiplying such a malformed zero value by another zero reached the negative-zero check in `decimal_mul`, where there were no digit words to scan, leading to assertion failure. Fix: Fix `do_div_mod`, which produced the malformed zero. `do_div_mod` already normalizes this case to a canonical zero on the modulo path; do the same on the division path: when the quotient has no digits (intg0 = 0 && frac0 = 0) return a correct decimal zero instead of a digit-less, signed value.
66325cf to
cc02edb
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.
fixes MDEV-39744
Problem:
With
div_precision_increment=0, a division whose quotient rounds away to zero (e.g. -299/450) produced a decimal with no digit words (intg=0 and frac=0) while still keeping the sign bit set. That is a malformed value.Multiplying such a malformed zero value by another zero reached the negative-zero check in
decimal_mul, where there were no digit words to scan, leading to assertion failure.Fix:
Fix
do_div_mod, which produced the malformed zero.do_div_modalready normalizes this case to a canonical zero on the modulo path; do the same on the division path: when the quotient has no digits (intg0 == 0 && frac0 == 0) return a correct decimal zero instead of a digit-less, signed value.