GNU bug report logs - #75745
[PATCH] gnu: hugs: Ignore integer overflow.

Previous Next

Package: guix-patches;

Reported by: Homo <gay <at> disroot.org>

Date: Wed, 22 Jan 2025 05:52:02 UTC

Severity: normal

Tags: moreinfo, patch

Full log


View this message in rfc822 format

From: Homo <gay <at> disroot.org>
To: 75745 <at> debbugs.gnu.org
Cc: Homo <gay <at> disroot.org>
Subject: [bug#75745] [PATCH] gnu: hugs: Ignore integer overflow.
Date: Wed, 22 Jan 2025 07:42:17 +0200
This is required to bootstrap MicroHs.

* gnu/packages/patches/hugs-ignore-integer-overflow.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/hugs.scm (hugs)[source]: Use it.

Change-Id: Ie13085d356f98d4dbb0fd1108b7179ad5226720f
---
See https://github.com/augustss/MicroHs/tree/hugs

It's a strong requirement from Lennart to not remove usage of pattern guards in MicroHs's code, so need help from someone experienced with YACC to add pattern guards support to Hugs, a nice to have, but not required, cherry on top of that: adding bang patterns and "instance forall" support in Hugs.

 gnu/local.mk                                  |  1 +
 gnu/packages/hugs.scm                         |  2 +-
 .../hugs-ignore-integer-overflow.patch        | 55 +++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/hugs-ignore-integer-overflow.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f118fe4442..ecea6ae9c7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1569,6 +1569,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/hubbub-sort-entities.patch		\
   %D%/packages/patches/hueplusplus-mbedtls.patch		\
   %D%/packages/patches/hugs-fix-build.patch			\
+  %D%/packages/patches/hugs-ignore-integer-overflow.patch	\
   %D%/packages/patches/hurd-64bit.patch				\
   %D%/packages/patches/hurd-refcounts-assert.patch		\
   %D%/packages/patches/hurd-rumpdisk-no-hd.patch		\
diff --git a/gnu/packages/hugs.scm b/gnu/packages/hugs.scm
index b6a97ea78c..ae7acbd511 100644
--- a/gnu/packages/hugs.scm
+++ b/gnu/packages/hugs.scm
@@ -37,7 +37,7 @@ (define-public hugs
       (sha256
        (base32
         "1mdy4aq4campgmnpc2qwq7bsbfhaxfsqdghbyyz2wms4lnfcmyma"))
-      (patches (search-patches "hugs-fix-build.patch"))))
+      (patches (search-patches "hugs-fix-build.patch" "hugs-ignore-integer-overflow.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(#:phases
diff --git a/gnu/packages/patches/hugs-ignore-integer-overflow.patch b/gnu/packages/patches/hugs-ignore-integer-overflow.patch
new file mode 100644
index 0000000000..ef0b7de824
--- /dev/null
+++ b/gnu/packages/patches/hugs-ignore-integer-overflow.patch
@@ -0,0 +1,55 @@
+From a87d3a15194e4d7724627e43a94ac1d12ab78f9c Mon Sep 17 00:00:00 2001
+From: Lennart Augustsson <lennart <at> augustsson.net>
+Date: Tue, 21 Jan 2025 12:26:15 -0700
+Subject: [PATCH] Ignore overflow in conversion from Integer to Int.
+
+---
+ src/bignums.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/src/bignums.c b/src/bignums.c
+index 32ce528..38ec43f 100644
+--- a/src/bignums.c
++++ b/src/bignums.c
+@@ -196,10 +196,18 @@ Bignum n; {
+ 		while (nonNull(ds=tl(ds))) {
+ 		    Int d = digitOf(hd(ds));
+ 		    if (b > (Int)(MAXHUGSWORD/BIGBASE))
+-			return NIL;
++#if 0
++                      return NIL;
++#else
++                      fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ 		    b *= BIGBASE;
+ 		    if (d > (Int)((MAXHUGSWORD - m)/b))
+-			return NIL;
++#if 0
++                      return NIL;
++#else
++                      fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ 		    m += b*d;
+ 		}
+ 	    } else { /* fst(n)==NEGNUM */
+@@ -207,10 +215,18 @@ Bignum n; {
+ 		while (nonNull(ds=tl(ds))) {
+ 		    Int d = - digitOf(hd(ds));
+ 		    if (b > (MAXPOSINT/BIGBASE))
+-			return NIL;
++#if 0
++                      return NIL;
++#else
++                      fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ 		    b *= BIGBASE;
+ 		    if (d < (MINNEGINT - m)/b)
+-			return NIL;
++#if 0
++                      return NIL;
++#else
++                      fprintf(stderr, "Warning: bigToInt overflow ignored\n");
++#endif
+ 		    m += b*d;
+ 		}
+ 	    }
-- 
2.47.1





This bug report was last modified 106 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.