[med-svn] [Git][med-team/mrbayes][master] 2 commits: Fix i386 rate normalization infinite loop

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Nov 9 07:22:12 GMT 2026



Andreas Tille pushed to branch master at Debian Med / mrbayes


Commits:
e5d4efe7 by Andreas Tille at 2026-11-09T08:11:50+01:00
Fix i386 rate normalization infinite loop

On i386, x87 excess precision may evaluate the float RATE_MIN constant in wider precision than the double rate values. A rate that has just been clamped to RATE_MIN then still compares as strictly smaller than RATE_MIN, so the normalization loops in Move_Revmat_Dir and Move_Revmat_DirMix clamp it again on every iteration and never terminate, making the build-time tests hang.

Use a MrBFlt copy of RATE_MIN for the comparisons so that the threshold and the rate values are always evaluated at the same precision.

Assisted-By: DeepSeek V4.1 Flash Free

- - - - -
bf4d314b by Andreas Tille at 2026-11-09T08:21:45+01:00
Upload to unstable

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/fix_i386_rate_min_loop.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,11 +1,11 @@
-mrbayes (3.2.9-1) UNRELEASED; urgency=medium
+mrbayes (3.2.9-1) unstable; urgency=medium
 
-  TODO: Fix build time test for i386
   * New upstream version
   * Drop 'Rules-Requires-Root: no' from d/control (routine-update)
   * Use dh_missing --fail-missing default
+  * Fix build-time test hang on i386: use a double-precision copy of RATE_MIN
 
- -- Andreas Tille <tille at debian.org>  Thu, 05 Nov 2026 15:58:23 +0100
+ -- Andreas Tille <tille at debian.org>  Mon, 09 Nov 2026 08:12:12 +0100
 
 mrbayes (3.2.7a-8) unstable; urgency=medium
 


=====================================
debian/patches/fix_i386_rate_min_loop.patch
=====================================
@@ -0,0 +1,116 @@
+Description: Fix infinite rate-normalization loop on i386
+ The rate normalization loops in Move_Revmat_Dir and Move_Revmat_DirMix
+ compare double-precision rate values against the float constant RATE_MIN.
+ On i386, x87 excess precision may evaluate the constant in wider precision
+ than the stored double value, so that a rate which has just been clamped to
+ RATE_MIN still compares as strictly smaller than RATE_MIN.  The loop then
+ clamps it again on every iteration and never terminates, which makes the
+ build-time test suite hang on i386.
+ .
+ Use a MrBFlt (double) copy of RATE_MIN for the comparisons so that the
+ threshold and the rate values always have the same precision.
+Author: Andreas Tille <tille at debian.org>
+Last-Update: 2026-11-09
+Assisted-By: DeepSeek V4.1 Flash Free
+
+diff --git a/src/proposal.c b/src/proposal.c
+index 4e1f7b7..4691eb6 100644
+--- a/src/proposal.c
++++ b/src/proposal.c
+@@ -14873,7 +14873,7 @@ int Move_Revmat_Dir (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRat
+     /* change revMat using Dirichlet proposal */
+     
+     int             i, nRates,isValid;
+-    MrBFlt          oldRate[200], newRate[200], dirParm[200], *value, sum, x, y, rate_pot, *alphaDir, alphaPi;
++    MrBFlt          oldRate[200], newRate[200], dirParm[200], *value, sum, x, y, rate_pot, rateMin, *alphaDir, alphaPi;
+     ModelParams     *mp;
+     ModelInfo       *m;
+ 
+@@ -14906,6 +14906,12 @@ int Move_Revmat_Dir (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRat
+     DirichletRandomVariable (dirParm, newRate, nRates, seed);
+ 
+     /* check new values. we rely on newRate be already normalized  */
++    /* Use a MrBFlt copy of RATE_MIN for the comparisons below. RATE_MIN
++       is a float constant; on i386 (x87 excess precision) it may be
++       evaluated in wider precision than the double values it is compared
++       against, so that a value stored as RATE_MIN still tests as smaller
++       than RATE_MIN. The normalization loop would then never terminate. */
++    rateMin = RATE_MIN;
+     while (1)
+         {
+         sum = 0.0;
+@@ -14913,14 +14919,14 @@ int Move_Revmat_Dir (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRat
+         isValid=1;
+         for (i=0; i<nRates; i++)
+             {
+-            if (newRate[i] <= RATE_MIN)
++            if (newRate[i] <= rateMin)
+                 {
+-                if (newRate[i] < RATE_MIN)
++                if (newRate[i] < rateMin)
+                     {
+-                    newRate[i] = RATE_MIN;
++                    newRate[i] = rateMin;
+                     isValid=0;
+                     }
+-                rate_pot -= RATE_MIN;
++                rate_pot -= rateMin;
+                 }
+             else
+                 sum += newRate[i];
+@@ -14928,7 +14934,7 @@ int Move_Revmat_Dir (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRat
+         if (isValid==1) break;
+         for (i=0; i<nRates; i++)
+             {
+-            if (newRate[i]!=RATE_MIN)
++            if (newRate[i]!=rateMin)
+                 newRate[i] = rate_pot * newRate[i] / sum;
+             }
+         }
+@@ -14988,7 +14994,7 @@ int Move_Revmat_Dir (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRat
+ int Move_Revmat_DirMix (Param *param, int chain, RandLong *seed, MrBFlt *lnPriorRatio, MrBFlt *lnProposalRatio, MrBFlt *mvp)
+ {
+     int         i, j, k, isValid, *growthFxn, nRates, groupSize[6];
+-    MrBFlt      *value, dirParm[6], newRate[6], oldRate[6], alphaPi, symDir, sum, rate_pot, x, y;
++    MrBFlt      *value, dirParm[6], newRate[6], oldRate[6], alphaPi, symDir, sum, rate_pot, rateMin, x, y;
+     ModelParams *mp;
+ 
+     /* get model params and settings */
+@@ -15026,6 +15032,9 @@ int Move_Revmat_DirMix (Param *param, int chain, RandLong *seed, MrBFlt *lnPrior
+     DirichletRandomVariable (dirParm, newRate, nRates, seed);
+ 
+     /* check new values. we rely on newRate be already normalized  */
++    /* Use a MrBFlt copy of RATE_MIN so that the comparisons are done
++       consistently in double precision (see Move_Revmat_Dir). */
++    rateMin = RATE_MIN;
+     while (1)
+         {
+         sum = 0.0;
+@@ -15033,14 +15042,14 @@ int Move_Revmat_DirMix (Param *param, int chain, RandLong *seed, MrBFlt *lnPrior
+         isValid=1;
+         for (i=0; i<nRates; i++)
+             {
+-            if (newRate[i] <= RATE_MIN)
++            if (newRate[i] <= rateMin)
+                 {
+-                if (newRate[i] < RATE_MIN)
++                if (newRate[i] < rateMin)
+                     {
+-                    newRate[i] = RATE_MIN;
++                    newRate[i] = rateMin;
+                     isValid=0;
+                     }
+-                rate_pot -= RATE_MIN;
++                rate_pot -= rateMin;
+                 }
+             else
+                 sum += newRate[i];
+@@ -15048,7 +15057,7 @@ int Move_Revmat_DirMix (Param *param, int chain, RandLong *seed, MrBFlt *lnPrior
+         if (isValid==1) break;
+         for (i=0; i<nRates; i++)
+             {
+-            if (newRate[i] != RATE_MIN)
++            if (newRate[i] != rateMin)
+                 newRate[i] = rate_pot * newRate[i] / sum;
+             }
+         }


=====================================
debian/patches/series
=====================================
@@ -1,3 +1,4 @@
 no_rpath.patch
 autoreconf.patch
 no_baseline_violation.patch
+fix_i386_rate_min_loop.patch



View it on GitLab: https://salsa.debian.org/med-team/mrbayes/-/compare/ee1f23fe273b1657b2baf7e817a3a22dec11d6eb...bf4d314b79d075f5b6cf5abc1332a8c014e10631

-- 
View it on GitLab: https://salsa.debian.org/med-team/mrbayes/-/compare/ee1f23fe273b1657b2baf7e817a3a22dec11d6eb...bf4d314b79d075f5b6cf5abc1332a8c014e10631
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261109/7999bcbb/attachment-0001.htm>


More information about the debian-med-commit mailing list