[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] parley bug ? (was: destructive sort! really destruct
From: |
Claude Marinier |
Subject: |
Re: [Chicken-users] parley bug ? (was: destructive sort! really destructive) |
Date: |
Sat, 24 May 2014 17:06:17 -0400 (EDT) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
On Sat, 24 May 2014, Claude Marinier wrote:
On Sat, 24 May 2014, Mario Domenech Goulart wrote:
Hi Claude,
On Sat, 24 May 2014 13:17:33 -0400 (EDT) Claude Marinier
<address@hidden> wrote:
Bonjour,
I decided to play with this but it went wrong.
First, start 'csi'.
address@hidden ~]$ /opt/chicken/bin/csi
CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0rc1 (rev 3cf1967)
linux-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2014-04-17 on hd-t1179cl (Linux)
; loading /home/claude/.csirc ...
; loading /opt/chicken/lib/chicken/7/parley.import.so ...
; loading /opt/chicken/lib/chicken/7/chicken.import.so ...
; loading /opt/chicken/lib/chicken/7/data-structures.import.so ...
; loading /opt/chicken/lib/chicken/7/extras.import.so ...
; loading /opt/chicken/lib/chicken/7/ports.import.so ...
; loading /opt/chicken/lib/chicken/7/posix.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-1.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-13.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-18.import.so ...
; loading /opt/chicken/lib/chicken/7/stty.import.so ...
; loading /opt/chicken/lib/chicken/7/srfi-69.import.so ...
; loading /opt/chicken/lib/chicken/7/foreign.import.so ...
; loading /opt/chicken/lib/chicken/7/foreigners.import.so ...
; loading /opt/chicken/lib/chicken/7/parley.so ...
; loading /opt/chicken/lib/chicken/7/stty.so ...
Define the list.
#;1>(define a
'((23 14 19) (28 9 19) (10 10 19) (16 14 18)
(14 8 18) (25 13 18) (13 13 17) (10 7 17)
(27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14)
(5 3 13) (23 2 12) (16 1 11) (29 0 10)
(15 8 9) (9 5 9) (4 7 8) (17 6 7)
(17 5 6) (28 3 4) (10 0 4) (7 2 3)
(20 1 2) (11 0 1))
)
Display the list.
#;2>(display a)
This produces an endlessly repeating stream of errors. Capturing it
was "interesting".
Error: (substring) out of range
0
-32
Call history:
parley.scm:285: loop
parley.scm:284: reverse
list->string
parley.scm:284: string-split
parley.scm:507: read-raw
parley.scm:476: call-with-current-continuation
parley.scm:478: prompt-loop
parley.scm:419: refresh-line
parley.scm:140: ##sys#call-with-values
parley.scm:141: terminal-size
parley.scm:386: -
parley.scm:389: -
parley.scm:390: floor
parley.scm:392: min
parley.scm:394: modulo
parley.scm:395: substring <--
((23 14 19) (28 9 19) (10 10 19) (16 14 18) (14 8 18) (25 13 18)
(13 13 17) (10 7 17) (27 12 17) (21 12 16) (10 6 16) (5 11 16)
(25 11 15) (6 5 15) (0 10 15) (3 4 14) (5 3 13) (23 2 12) (16 1 11)
(29 0 10) (15 8 9) (9 5 9) (4 7 8) (17 6 7) (17 5 6) (28 3 4)
(10 0 4) (7 2 3) (20 1 2) (11 0 1))
Something is broken. Is it my build or Chicken itself?
I suppose it's something related to parley. Can you try to run the
interactive repl as "csi -n"? Alternatively, you can run it
non-interactively: csi -s list-of-triplets.scm
Correct. It works as expected with both suggested approaches.
It looks like an arithmetic problem, probably while calculating 'end'. No,
that's too simple. Parley has been working well, so this must be an odd
combination of factors. It looks too complicated for me.
Christian, you're most familiar with this. What do you think?
(define (refresh-line prompt port line pos offset)
(let* ((cols (- (get-terminal-columns port)
offset 3))
(plen (+ offset (string-length prompt)))
(chunk-size (- cols offset 1))
(chunkno (inexact->exact (floor (/ pos chunk-size))))
(start (* chunk-size chunkno))
(end (min (string-length line)
(+ start chunk-size)))
(npos (modulo (- pos start) chunk-size))
(delimited-line (substring line start end)))
...
I asked parley's 'refresh-line' to dump some information. I split the
'let' and added the code before the 'substring'.
line ""
line length 0
offset 54 cols 23 plen 62 chunkno 0 chunksize -32 start 0 end -32 npos 0
Error: (substring) out of range
0
-32
Call history:
parley.scm:482: prompt-loop
parley.scm:423: refresh-line
parley.scm:140: ##sys#call-with-values
parley.scm:141: terminal-size
parley.scm:386: -
parley.scm:389: -
parley.scm:390: floor
parley.scm:392: min
parley.scm:394: modulo
parley.scm:395: newline
parley.scm:396: print
parley.scm:397: newline
parley.scm:398: print
parley.scm:399: newline
parley.scm:400: print
parley.scm:401: substring <--
Note that the code runs without error when the 'urxvt' window is 90
columns. Ow! it segfaults at 82 columns.
'((23 14 19) (28 9 19) (10 10 19)
line "'((23 14 19) (28 9 19) (10 10 19) ("
line length 35
offset 1 cols 76 plen 3 chunkno 0 chunksize 74 start 0 end 35 npos 35
'((23 14 19) (28 9 19) (10 10 19) (Segmentation fault
--
Claude Marinier