Skip to content
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

MDEV-34621: Fix division by zero in mariadb-slap when iterations=0 #3892

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

KhaledR57
Copy link

@KhaledR57 KhaledR57 commented Mar 14, 2025

  • The Jira issue number for this PR is: MDEV-34621

Description

mariadb-slap crashes with a floating point exception when run with -i0 due to division by zero in generate_stats(). This occurs when calculating average timing by dividing by the number of iterations.
Instead of modifying the minimum value for the -i option (which would cause unexpected warning messages even with valid values), this PR implements a targeted fix in the generate_stats(). The solution checks if iterations == 0 before performing the division, and in such cases, returns early from the function.

Release Notes

Fixed a floating point exception (division by zero) crash in mariadb-slap when running with -i0 (zero iterations).

How can this PR be tested?

This PR can be tested by manually running mariadb-slap with zero iterations, which would previously cause a crash:

$ mariadb-slap -i0 --only-print

Or

$ ./mtr main.mysqlslap

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@cvicentiu cvicentiu added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 14, 2025
Copy link
Contributor

@svoj svoj left a comment

Choose a reason for hiding this comment

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

Please add a test case and amend your fix.

@KhaledR57 KhaledR57 force-pushed the MDEV-34621 branch 2 times, most recently from 8192b45 to 88a6cfd Compare March 20, 2025 00:25
Copy link
Contributor

@svoj svoj left a comment

Choose a reason for hiding this comment

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

Adjust commit comment according to https://github.com/MariaDB/server/blob/11.0/CODING_STANDARDS.md

That is split long lines. Sentences should end with period.

Could you also retarget it for 10.6? Or I can do it myself once PR is approved.

@KhaledR57 KhaledR57 changed the base branch from 11.4 to 10.6 March 20, 2025 19:30
@KhaledR57 KhaledR57 changed the base branch from 10.6 to 11.4 March 20, 2025 19:31
@CLAassistant
Copy link

CLAassistant commented Mar 20, 2025

CLA assistant check
All committers have signed the CLA.

@svoj svoj changed the base branch from 11.4 to 10.6 March 20, 2025 20:12
@svoj svoj changed the base branch from 10.6 to 10.11 March 21, 2025 08:46
mariadb-slap crashes with a floating point exception when run with
-iterations=0 due to division by zero in generate_stats(). This occurs
when calculating average timing by dividing by the number of iterations.

To fix this, the solution checks if iterations == 0 before performing
the division, and returns early from the function in such cases.
@svoj svoj merged commit f813c85 into MariaDB:10.11 Mar 21, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.
Development

Successfully merging this pull request may close these issues.

4 participants