[gambit-list] Consistent, small program segmentation fault between 4.6.7 and 4.5.8

Bradley Lucier lucier at math.purdue.edu
Mon Jun 3 21:37:45 EDT 2013


Marc:

The program at the end works in 4.6.7, fails in 4.6.8 in the following 
environment:

Works:

frying-pan:~/lang/scheme/chudnovsky> gsi -v
v4.6.7 20130219214006 x86_64-unknown-linux-gnu "./configure 
'--enable-single-host' '--enable-shared' '--enable-multiple-versions'"

Doesn't work:

frying-pan:~/lang/scheme/chudnovsky> gsi -v
v4.6.8 20130430024640 x86_64-unknown-linux-gnu "./configure 
'--enable-single-host' '--enable-shared' '--enable-multiple-versions'"
frying-pan:~/lang/scheme/chudnovsky> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 
4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs 
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-4.7 --enable-shared --enable-linker-build-id 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib 
--enable-nls --with-sysroot=/ --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--enable-gnu-unique-object --enable-plugin --with-system-zlib 
--enable-objc-gc --with-cloog --enable-cloog-backend=ppl 
--disable-cloog-version-check --disable-ppl-version-check 
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 
--with-multilib-list=m32,m64,mx32 --with-tune=generic 
--enable-checking=release --build=x86_64-linux-gnu 
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
frying-pan:~/lang/scheme/chudnovsky> uname -a
Linux frying-pan 3.8.0-23-generic #34-Ubuntu SMP Wed May 29 20:22:58 UTC 
2013 x86_64 x86_64 x86_64 GNU/Linux
frying-pan:~/lang/scheme/chudnovsky> gsi -e '(load "chud1.scm")'
| > (ch-split 0 7053)
| | > (ch-split 0 3526)
<lots of stuff removed>
| | | | | | | |[13] > (ch-split 73 75)
| | | | | | | |[14] > (ch-split 73 74)
| | | | | | | |[14] (28588119 4432769187497607168000 1153643848480497675)
| | | | | | | |[14] > Segmentation fault (core dumped)

Brad



;;; Program to use the chudnovsky formula to compute pi.
;;; Written by Bakul Shah.
;;; Changed by Bradley Lucier to use standard arithmetic operations
;;; available in Gambit Scheme.

     (define ch-A 13591409)
     (define ch-B 545140134)
     (define ch-C 640320)
     (define ch-C^3 (expt 640320 3))
     (define ch-D 12)

     (define (ch-split a b)
       (if (= 1 (- b a))
         (let ((g (* (- (* 6 b) 5) (- (* 2 b) 1) (- (* 6 b) 1))))
           (list g
                 (floor (/ (* ch-C^3 (expt b 3)) 24))
                 (* (expt -1 b) g (+ (* b ch-B) ch-A))))
         (let* ((mid (floor (/ (+ a b) 2)))
                (gpq1 (ch-split a mid))    ;<<<<====
                (gpq2 (ch-split mid b))    ;<<<<====
                (g1 (car gpq1)) (p1 (cadr gpq1)) (q1 (caddr gpq1))
                (g2 (car gpq2)) (p2 (cadr gpq2)) (q2 (caddr gpq2)))
           (list (* g1 g2)
                 (* p1 p2)
                 (+ (* q1 p2) (* q2 g1))))))

     (define (pi digits)
           (let* ((num-terms (inexact->exact (floor (+ 2 (/ digits 
14.181647462)))))
                  (sqrt-C (integer-sqrt (* ch-C (expt 100 digits)))))
           (let* ((gpq (ch-split 0 num-terms))
                  (g (car gpq)) (p (cadr gpq)) (q (caddr gpq)))
             (floor (/ (* p ch-C sqrt-C) (* ch-D (+ q (* p ch-A))))))))
(trace ch-split)
(pi 100000)



More information about the Gambit-list mailing list