Skip to content

MDEV-39744: Assertion buf != end failed in decimal_mul#5265

Open
raghunandanbhat wants to merge 1 commit into
10.11from
10.11-mdev-39744
Open

MDEV-39744: Assertion buf != end failed in decimal_mul#5265
raghunandanbhat wants to merge 1 commit into
10.11from
10.11-mdev-39744

Conversation

@raghunandanbhat

@raghunandanbhat raghunandanbhat commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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_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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread mysql-test/main/type_newdecimal.test Outdated
@raghunandanbhat raghunandanbhat requested a review from vuvova June 22, 2026 14:34
@raghunandanbhat raghunandanbhat force-pushed the 10.11-mdev-39744 branch 2 times, most recently from 1a16cbf to 66325cf Compare June 23, 2026 07:36
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant