🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #7435

Bug#1067631: src:altree: autopkgtest timeouts on armel, armhf and ppc64el

#7435
From: Andreas Tille
Date: Fri, 04 Dec 2026 09:00
73 lines
4965 bytes
Hi Etienne,

thanks for narrowing this down to rhyper().  I think I found the root
cause, and I do not think we need to drop any architecture.

CUtils/c_sources/rhyper.c builds a lazy cache of exact log factorials in
afc(): the factorial itself is kept in a `long double` and only converted
to a log afterwards:

    static long double cur=3628800;
    ...
    cur *= i;
    data->al[i+1] = logl(cur);

`long double` has the same exponent range as `double` on armel/armhf (it
is `double` there) and on ppc64el (IBM double-double): about 1.8e308.
170! is still representable (7.3e306), but 171! overflows to +Inf.  So on
exactly these architectures every afc(i) with i >= 171 returns +Inf; on
amd64/i386 the x87 80-bit long double reaches 1e4932 and nothing
overflows.  That explains why only these three architectures hang.

How that freezes the test: the example data has 102 cases and 74 controls,
so rhyper(102, 74, s) is called with nn1+nn2 = 176 and afc(176) = +Inf.
In the case II (inverse transformation) branch

    w = exp(con + afc(n2) + afc(n1+n2-k) - afc(n2-k) - afc(n1+n2));

this becomes exp(-Inf) = 0 for k >= 6 (for k <= 5 it is NaN, which
terminates but does not return a proper random variate), so p starts at 0,
`u > p` is always true, ix walks up to maxjx, jumps back to L10 and the
loop repeats forever.  Case III has the same problem: the exact acceptance
test becomes Inf - Inf = NaN, so every candidate is rejected and L30 loops
forever (reproducible with rhyper(400, 400, 400)).

Reproduction without the affected hardware: take rhyper.c, replace
`long double` with `double` (same exponent range as on armel/armhf/
ppc64el), link it with mt19937ar.c and call rhyper(102,74,k).  k = 6..22
loop forever, while the amd64 build returns immediately.  With the patch
below the double build terminates for every k and gives exactly the same
sequence of results as the amd64 build.  (I did not use gcc's
-mlong-double-64 for this because on x86-64 it is not ABI-compatible with
glibc's logl.)

The fix is to keep the exact table only as long as the factorial fits into
a double and to use the existing Stirling branch beyond that, which is
what R's afc() does anyway:

--- a/CUtils/c_sources/rhyper.c
+++ b/CUtils/c_sources/rhyper.c
@@ -105,7 +105,12 @@ static double afc(int i)
       exit(1);
     } else if (i <= data.computed) {
 	value = data.al[i + 1];
-    } else if (i <= 1754) {
+    /* 170! is the largest factorial that fits in a double.  On platforms
+     * where long double has the same exponent range as double (armel,
+     * armhf, ppc64el, ...), cur would overflow to +Inf from 171 on and
+     * every afc() value beyond that would be +Inf, making rhyper() loop
+     * forever.  Use Stirling's approximation there, as R does. */
+    } else if (i <= 170) {
 	value = compute(i, &data);
     } else {
 	di = i;

The error of the Stirling branch is around 1e-10, far below the
deltal/deltau safety margins (7.8e-3 / 3.4e-3) of the algorithm.

Unless someone objects, I will apply this as a Debian patch, upload it,
and forward it upstream, so the package can keep the full architecture
list.

Kind regards,
 Andreas
Technical Details
Message-ID: <O6xj3-fU8h-3@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ro.newsdeef.eu!srl.newsdeef.eu!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
References: <IlCX0-1qs9-53@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ro.newsdeef.eu!srl.newsdeef.eu!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Andreas Tille <tille@debian.org>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1067631: src:altree: autopkgtest timeouts on armel, armhf and ppc64el
Date: Fri, 04 Dec 2026 10:00:01 +0100
Message-ID: <O6xj3-fU8h-3@gated-at.bofh.it>
References: <IlCX0-1qs9-53@gated-at.bofh.it>
X-Original-To: 1067631@bugs.debian.org
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Fri Dec  4 08:51:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.9
Reply-To: Andreas Tille <tille@debian.org>, 1067631@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: debian-med-packaging@lists.alioth.debian.org
X-Debian-Pr-Message: followup 1067631
X-Debian-Pr-Package: src:altree
X-Debian-Pr-Keywords: confirmed help
X-Debian-Pr-Source: altree
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
X-Greylist: delayed 306 seconds by postgrey-1.37 at buxtehude; Fri, 04 Dec 2026 08:49:48 UTC
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2006896
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 73
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Fri, 04 Dec 2026 09:45:00 +0100
X-Original-Message-ID: <179637390059.3311835.16403659095330799041@debian.org>
X-Original-References: <2b0af7e0-94d7-46f5-ba82-f83a60e3d570@debian.org>