unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Jack Hill <jackhill@jackhill.us>, 49263@debbugs.gnu.org
Subject: bug#49263: Guix weather backtrace
Date: Tue, 29 Jun 2021 00:12:27 +0200	[thread overview]
Message-ID: <bad19196a4cf3f00a1988eb77d4fee183afa4d99.camel@telenet.be> (raw)
In-Reply-To: <alpine.DEB.2.21.2106281611160.2109@marsh.hcoop.net>


[-- Attachment #1.1: Type: text/plain, Size: 1180 bytes --]

Jack Hill schreef op ma 28-06-2021 om 16:15 [-0400]:
> computing 0 package derivations for aarch64-linux...
> [...]
> Throw to key `numerical-overflow' with args `("/" "Numerical overflow" #f #f)'.

A division by zero problem?
Also, this seems architecture-dependent:

$ guix weather icecat --system=x86_64-linux icecat

2 pakketdistillaties aan het berekenen voor x86_64-linux...
op zoek naar 2 depotobjecten op https://ci.guix.gnu.org...
https://ci.guix.gnu.org
  100.0% substituten beschikbaar (2 van de 2)
  ten minste 355,2 MiB aan narbestanden (gecomprimeerd)
  377,9 MiB op schijf (ongecomprimeerd)
  0,379 seconden per verzoek (0,8 seconden in totaal)
  2,6 verzoeken per seconde

$ guix weather icecat --system=aarch64-linux icecat

0 pakketdistillaties aan het berekenen voor aarch64-linux...
op zoek naar 0 depotobjecten op https://ci.guix.gnu.org...
https://ci.guix.gnu.org
Backtrace: [...]
Throw to key `numerical-overflow' with args `("/" "Numerical overflow" #f #f)'.

Seems like the definition of icecat or some dependency of icecat does
not support aarch64. Anyway, here is a patch. Could you confirm it works?

Greetings,
Maxime.

[-- Attachment #1.2: 0001-weather-Handle-zero-requested-store-items-gracefully.patch --]
[-- Type: text/x-patch, Size: 2776 bytes --]

From 1d87e33360c9897a77b7e172f16e3cd1973c959d Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Tue, 29 Jun 2021 00:06:34 +0200
Subject: [PATCH] weather: Handle zero requested store items gracefully.

This can happen if the weather information of a package
is requested for an unsupported system.  For example,
try "guix weather icecat --system=aarch64-linux".

* guix/scripts/weather.scm
  (report-server-coverage): Do not divide by zero when zero
  store items are requested from a server.

Fixes: <https://issues.guix.gnu.org/49263>
Reported-By: Jack Hill <jackhill@jackhill.us>
---
 guix/scripts/weather.scm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index 6d925d416c..06312d65a2 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -185,9 +186,12 @@ or #f if it could not be determined."
                                  #:key display-missing?)
   "Report the subset of ITEMS available as substitutes on SERVER.
 When DISPLAY-MISSING? is true, display the list of missing substitutes.
-Return the coverage ratio, an exact number between 0 and 1."
+Return the coverage ratio, an exact number between 0 and 1.
+In case ITEMS is an empty list, return 1 instead."
   (define MiB (* (expt 2 20) 1.))
 
+  ;; TRANSLATORS: it is quite possible zero store items are
+  ;; looked for.
   (format #t (G_ "looking for ~h store items on ~a...~%")
           (length items) server)
 
@@ -208,9 +212,10 @@ Return the coverage ratio, an exact number between 0 and 1."
                                  narinfos))
           (time      (+ (time-second time)
                         (/ (time-nanosecond time) 1e9))))
-      (format #t (G_ "  ~,1f% substitutes available (~h out of ~h)~%")
-              (* 100. (/ obtained requested 1.))
-              obtained requested)
+      (when (> requested 0)
+        (format #t (G_ "  ~,1f% substitutes available (~h out of ~h)~%")
+                (* 100. (/ obtained requested 1.))
+                obtained requested))
       (let ((total (/ (reduce + 0 sizes) MiB)))
         (match (length sizes)
           ((? zero?)
@@ -299,7 +304,9 @@ are queued~%")
 
       ;; Return the coverage ratio.
       (let ((total (length items)))
-        (/ (- total (length missing)) total)))))
+        (if (> total 0)
+            (/ (- total (length missing)) total)
+            1)))))
 
 \f
 ;;;
-- 
2.32.0


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2021-06-28 22:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 20:15 bug#49263: Guix weather backtrace Jack Hill
2021-06-28 22:12 ` Maxime Devos [this message]
2021-06-29  3:29   ` Jack Hill
2021-06-29  8:12     ` Maxime Devos
2021-06-29 18:22   ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bad19196a4cf3f00a1988eb77d4fee183afa4d99.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=49263@debbugs.gnu.org \
    --cc=jackhill@jackhill.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).