chiark / gitweb /
Fix occasional 'min fragment 1.11022e-16' glitch.
authorSimon Tatham <anakin@pobox.com>
Sun, 9 Mar 2014 23:14:24 +0000 (23:14 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 9 Mar 2014 23:14:24 +0000 (23:14 +0000)
Seems to happen in multicore mode when the first worker reports a
near-zero value of 'best', and then set_best reduces it to a negative
number when it applies the rounding fudge, leading to the max_frags
limits being set to negative things and all other workers' results
being thrown away in preconsider_ok().

main.c

diff --git a/main.c b/main.c
index a57bd7231a60248d0b9b81c1df24600c12c26d6e..8259c35a968bb1525670e413f20281d9b38b49f1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -147,8 +147,10 @@ static void set_best(double new_best) {
    * subtract a fudge factor from our target.
    */
   double near_best = best * 0.98 - 0.02;
-  n_max_frags = ceil(n / near_best) - 1;
-  m_max_frags = ceil(m / near_best) - 1;
+  if (near_best > 0) {
+    n_max_frags = ceil(n / near_best) - 1;
+    m_max_frags = ceil(m / near_best) - 1;
+  }
 }
 
 /*----- multicore support -----*/