GNU bug report logs -
#24908
Possible unboxing bug in master triggered by (format)
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24908 in the body.
You can then email your comments to 24908 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#24908
; Package
guile
.
(Wed, 09 Nov 2016 13:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Daniel Llorens <daniel.llorens <at> bluewin.ch>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Wed, 09 Nov 2016 13:18:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(format #f "~2f" 9.9) fails in master. You can try different combinations, it doesn't fail when it rounds down or there're more spaces for example.
The first bad commit is 0f2f5949a21572fad8355473200c7adc6d74f882 'Better unboxing' on the master branch.
See the full error below. 18446744073709551615 is 2^64-1 of course so it looks like bad signedness somewhere.
Regards
Daniel
> guile -c '(use-modules (ice-9 format)) (format #f "~2f" 9.9)'
Backtrace:./meta/guile -c '(use-modules (ice-9 format)) (format #f "~2f" 9.9)'
Backtrace:
8 (apply-smob/1 #<catch-closure 1105c20>)
In ice-9/boot-9.scm:
704:2 7 (call-with-prompt ("prompt") #<procedure 110a060 at ic…> …)
In ice-9/eval.scm:
608:8 6 (_ #(#(#<directory (guile-user) 110cf30>)))
In ice-9/command-line.scm:
181:18 5 (_ #<input: string 1119f50>)
In unknown file:
4 (eval (format #f "~2f" 9.9) #<directory (guile-user) 11…>)
In ice-9/format.scm:
1590:19 3 (format #f "~2f" 9.9)
316:19 2 (format:format-work "~2f" (9.9))
1142:30 1 (format:out-fixed #f _ _)
1525:37 0 (format:fn-round _)
ice-9/format.scm:1525:37: In procedure format:fn-round:
ice-9/format.scm:1525:37: In procedure string-ref: Value out of range: 18446744073709551615
Information forwarded
to
bug-guile <at> gnu.org
:
bug#24908
; Package
guile
.
(Fri, 09 Dec 2016 13:12:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 24908 <at> debbugs.gnu.org (full text, mbox):
I can't fix the compiler, so just patch format:fn-round. Includes a
test.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#24908
; Package
guile
.
(Fri, 09 Dec 2016 13:12:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 24908 <at> debbugs.gnu.org (full text, mbox):
From: Daniel Llorens <daniel.llorens <at> bluewin.ch>
* module/ice-9/format.scm (format:fn-round): Don't let i become
negative.
* test-suite/tests/format.test: Regression test for "~2f".
---
module/ice-9/format.scm | 15 ++++++++-------
test-suite/tests/format.test | 6 +++++-
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm
index 1ef4cb5ef..d3066a527 100644
--- a/module/ice-9/format.scm
+++ b/module/ice-9/format.scm
@@ -1510,11 +1510,12 @@
(set! format:fn-len (- format:fn-len n)))
(string-set! format:fn-str (- i n) (string-ref format:fn-str i))))
+ ;; carry i+1 to work around bug #24908
(define (format:fn-round digits) ; round format:fn-str
(set! digits (+ digits format:fn-dot))
- (do ((i digits (- i 1)) ; "099",2 -> "10"
+ (do ((i (+ digits 1) (- i 1)) ; "099",2 -> "10"
(c 5)) ; "023",2 -> "02"
- ((or (= c 0) (< i 0)) ; "999",2 -> "100"
+ ((or (= c 0) (<= i 0)) ; "999",2 -> "100"
(if (= c 1) ; "005",2 -> "01"
(begin ; carry overflow
(set! format:fn-len digits)
@@ -1522,12 +1523,12 @@
(string-set! format:fn-str 0 #\1)
(set! format:fn-dot (+ format:fn-dot 1)))
(set! format:fn-len digits)))
- (set! c (+ (- (char->integer (string-ref format:fn-str i))
+ (set! c (+ (- (char->integer (string-ref format:fn-str (- i 1)))
format:zero-ch) c))
- (string-set! format:fn-str i (integer->char
- (if (< c 10)
- (+ c format:zero-ch)
- (+ (- c 10) format:zero-ch))))
+ (string-set! format:fn-str (- i 1) (integer->char
+ (if (< c 10)
+ (+ c format:zero-ch)
+ (+ (- c 10) format:zero-ch))))
(set! c (if (< c 10) 0 1))))
(define (format:fn-out modifier add-leading-zero?)
diff --git a/test-suite/tests/format.test b/test-suite/tests/format.test
index cc31942cc..8aab7e96b 100644
--- a/test-suite/tests/format.test
+++ b/test-suite/tests/format.test
@@ -112,7 +112,11 @@
;; in guile prior to 1.6.9 and 1.8.1, leading zeros were incorrectly
;; stripped, moving the decimal point and giving "25.0" here
(pass-if "string 02.5"
- (string=? "2.5" (format #f "~f" "02.5"))))
+ (string=? "2.5" (format #f "~f" "02.5")))
+
+ ;; regression against bug #24908
+ (pass-if "2f"
+ (string=? "10." (format #f "~2f" 9.9))))
;;;
;;; ~h
--
2.11.0
Reply sent
to
Daniel Llorens <daniel.llorens <at> bluewin.ch>
:
You have taken responsibility.
(Thu, 15 Dec 2016 12:00:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Daniel Llorens <daniel.llorens <at> bluewin.ch>
:
bug acknowledged by developer.
(Thu, 15 Dec 2016 12:00:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 24908-close <at> debbugs.gnu.org (full text, mbox):
Fixed in 2660c0b3c86bf76fab465c200a5ca20fb37cf811.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 12 Jan 2017 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 159 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.