chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-janitors] #876: csi segfaults immediately when running this


From: Chicken Trac
Subject: Re: [Chicken-janitors] #876: csi segfaults immediately when running this code
Date: Tue, 26 Jun 2012 11:58:16 -0000

#876: csi segfaults immediately when running this code
-------------------------+--------------------------------------------------
  Reporter:  ckeen       |       Owner:                     
      Type:  defect      |      Status:  new                
  Priority:  major       |   Milestone:  4.8.0              
 Component:  core tools  |     Version:  4.7.x              
Resolution:              |    Keywords:  csi segfault master
-------------------------+--------------------------------------------------
Description changed by ckeen:

Old description:

> As found by uman on IRC the following works when compiled and crashes
> when interpreted:
>
> {{{
> (define (inc x) (+ x 1))
>
> (define (product-rec f a next b)
>   (if (> a b) 1
>       (* (f a) (product-rec f (next a) next b))))
>
> (define (fact n)
>   (product-rec identity 1 inc n))
>
> (define (estimate-pi n)
>   (define (num-term k)
>     (+ k (if (even? k) 2 1)))
>   (define (denom-term k)
>     (+ k (if (even? k) 1 2)))
>   (* 4 (product-rec (lambda (k) (/ (num-term k) (denom-term k))) 1 inc
> n)))
>
> (define (product-iter f a next b)
>   (let loop ((accum 1) (x a))
>     (if (> x b) accum
>       (loop (* accum (f x)) (next x)))))
>
> (print (estimate-pi 100000))
> }}}
>
> This crashes current master, on x64 linux, also 4.7.0 on 32bit x86
> OpenBSD

New description:

 As found by uman on IRC the following works when compiled and crashes when
 interpreted:

 {{{
 (define (product-rec f a next b)
   (if (> a b) 1
       (* (f a) (product-rec f (next a) next b))))

 (define (estimate-pi n)
   (define (num-term k)
     (+ k (if (even? k) 2 1)))
   (define (denom-term k)
     (+ k (if (even? k) 1 2)))
   (* 4 (product-rec (lambda (k) (/ (num-term k) (denom-term k))) 1 add1
 n)))

 (print (estimate-pi 100000))

 }}}

 This crashes current master, on x64 linux, also 4.7.0 on 32bit x86 OpenBSD

--

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/876#comment:1>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]