diff options
| author | Scott Gasch <[email protected]> | 2026-08-27 08:52:40 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-08-27 08:52:40 -0700 |
| commit | 489915f4c98c7aca3a63c0f35b83929e8331a597 (patch) | |
| tree | a8554919ca44f5551001768a3dcac546bfd0af0f /src | |
| parent | 4ce6a76b0946e4ba943d29c506c9e2fb00601efd (diff) | |
Fix integer divide-by-zero in script.c's post-suite histogram printer.
uMax (the largest histogram bucket count) can be 0 when a script run's
positions are all unsolved -- ASSERT(uMax > 0) doesn't stop this in a
non-DEBUG build, and the following loop unconditionally divides by
uMax, crashing with SIGFPE. Hit repeatedly today running single-position
diagnostic scripts (an isolated unsolved position naturally has an
all-zero histogram) while investigating an LMR regression on ECM.213.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGSMkwjqiCk4XhbfN7ugD2
Diffstat (limited to 'src')
| -rwxr-xr-x | src/script.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/script.c b/src/script.c index 085f9ec..142b42c 100755 --- a/src/script.c +++ b/src/script.c @@ -479,14 +479,13 @@ Return value: uMax = g_SuiteCounters.uHistogram[u]; } } - ASSERT(uMax > 0); - for (u = 0; u < SUITE_NUM_HISTOGRAM; u++) + for (u = 0; u < SUITE_NUM_HISTOGRAM; u++) { - Trace("%4.1f .. %4.1f: ", + Trace("%4.1f .. %4.1f: ", (double)u * dMult, (double)(u + 1) * dMult); - for (v = 0; - v < 50 * g_SuiteCounters.uHistogram[u] / uMax; - v++) + for (v = 0; + (uMax > 0) && (v < 50 * g_SuiteCounters.uHistogram[u] / uMax); + v++) { Trace("*"); } |
