MDEV-34621: Fix division by zero in mariadb-slap when iterations=0 #3892
+16
−5
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.
Description
mariadb-slap
crashes with a floating point exception when run with-i0
due to division by zero ingenerate_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 thegenerate_stats()
. The solution checks ifiterations == 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:
Or
Basing the PR against the correct MariaDB version
main
branch.PR quality check