From 489915f4c98c7aca3a63c0f35b83929e8331a597 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Thu, 27 Aug 2026 08:52:40 -0700 Subject: 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 Claude-Session: https://claude.ai/code/session_01YGSMkwjqiCk4XhbfN7ugD2 --- src/script.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/script.c') 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("*"); } -- cgit v1.3