unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* Segfault when running fibc benchmark in current trunk
@ 2009-04-17  0:37 Juhani Rantanen
  2009-04-17  6:33 ` Andy Wingo
  2009-04-17  7:30 ` Andy Wingo
  0 siblings, 2 replies; 8+ messages in thread
From: Juhani Rantanen @ 2009-04-17  0:37 UTC (permalink / raw)
  To: bug-guile

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

Hi,

I noticed that vm is now in the trunk, so I decided to run some benchmarks
to test it for robustness. While doing this, I found a problem that seems
to be related to continuations, although guile crashes in gc. I have
attached a minimal and self-contained testcase here. Note that iterating
50 or so times is required to trigger the segfault so that is not "extra
code".

I have also found problems with other tests from the same benchmark, and
at least one of them is using call-with-current-continuation also (others
I have not looked at yet). I will report them as well, but right now I
don't have reduced testcases for them and they are likely duplicates.

Best Regards,
Juhani

[-- Attachment #2: fibc_bug.scm --]
[-- Type: application/octet-stream, Size: 1133 bytes --]

(define (run-bench name count ok? run)
  (let loop ((i count) (result '(undefined)))
    (if (< 0 i)
      (loop (- i 1) (run))
      result)))

(define (run-benchmark name count ok? run-maker . args)
  (newline)
  (let* ((run (apply run-maker args))
         (result (run-bench name count ok? run)))
    (if (not (ok? result))
      (begin
        (display "*** wrong result ***")
        (newline)
        (display "*** got: ")
        (write result)
        (newline)))))

(define (_1+ n) (+ n 1))
(define (_1- n) (- n 1))

;;; fib with peano arithmetic (using numbers) with call/cc

(define (addc x y k)
  (if (zero? y)
    (k x)
    (addc (_1+ x) (_1- y) k)))

(define (fibc x c)
  (if (zero? x)
    (c 0)
    (if (zero? (_1- x))
      (c 1)
      (addc (call-with-current-continuation (lambda (c) (fibc (_1- x) c)))
            (call-with-current-continuation (lambda (c) (fibc (_1- (_1- x)) c)))
            c))))

(define fibc-iters         50)

(define (main)
  (run-benchmark
    "fibc"
    fibc-iters
    (lambda (result) (equal? result 2584))
    (lambda (x c) (lambda () (fibc x c)))
    18
    (lambda (n) n)))
(main)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-05-03 21:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-17  0:37 Segfault when running fibc benchmark in current trunk Juhani Rantanen
2009-04-17  6:33 ` Andy Wingo
2009-04-17  7:30 ` Andy Wingo
2009-04-19 16:28   ` Juhani Rantanen
2009-04-19 22:02   ` Juhani Rantanen
     [not found]   ` <39231.87.93.21.245.1240178567.squirrel@webmail.aj-group.net>
2009-04-22 19:29     ` Juhani Rantanen
2009-04-22 19:59       ` Andy Wingo
2009-05-03 21:37         ` Juhani Rantanen

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).