On Apr 25, 2007, at 10:25 PM, dillo gimp wrote:
On 4/26/07, Bradley Lucier lucier@math.purdue.edu wrote:
I hope you don' t mind me CC'ing my reply to th list.
On Apr 25, 2007, at 9:05 PM, dillo gimp wrote:
On 4/26/07, Bradley Lucier lucier@math.purdue.edu wrote: On Apr 25, 2007, at 7:43 PM, dillo gimp wrote:
There might be a bug in big number handling, the same code runs fine under mzscheme and petite, but crashes
with
gambit : *** ERROR IN ##ratnum.* -- Divide by zero (quotient 0 0)
I don't even use "quotient" in my code.
We'd need to see a bit of your code to figure out what you *are* using.
I don't know how to make gambit to report exactly where the code has crashed. The program is not exactly small either. Can you tell me how to make gambit report "crash point"? This is my compilation steps:
cat /lfs/script/gambit.sh #!/bin/bash /usr/4.0b22/bin/gsc -prelude '(define (display x) (write x
(current-
output-port)))' -link $1 prog=${1%.sc} gcc -O2 -fomit-frame-pointer -freg-struct-return \ -I/usr/4.0b22/include -L/usr/4.0b22/lib \ -D___SINGLE_HOST -o $prog $prog.c ${prog}_.c -lgambc -lm -
ldl -
lutil
OK, well I still don't know what you're trying to do, but gambit requires gcc to use certain flags for to correctly compile gambit- generated code. See the options in /usr/4.0b22/bin/
I don't understand. I am following the exact steps from: http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html http://www.iro.umontreal.ca/~gambit/doc/gambit-c_toc.html#TOC17
The documentation is in error.
You are compiling your code with the options
gcc -O2 -fomit-frame-pointer -freg-struct-return \ -I/usr/4.0b22/include -L/usr/4.0b22/lib \ -D___SINGLE_HOST -o $prog $prog.c ${prog}_.c -lgambc -lm -
ldl -
These options are incorrect. You can find the correct options on your machine in
/usr/4.0b22/bin/gsc-cc-o
which is in the same directory in which you installed gsi and gsc.
This may be causing your specific problem, but I don't know for sure.
The program only reports: *** ERROR IN ##ratnum.* -- Divide by zero (quotient 0 0)
Without a more accurate location, I can't guess what's wrong.
The code for numeric operations is in gambc-4.0b22/lib/_num.scm. There you will find
(define-prim (##ratnum.* x y) (let ((p (macro-ratnum-numerator x)) (q (macro-ratnum-denominator x)) (r (macro-ratnum-numerator y)) (s (macro-ratnum-denominator y))) (if (##eq? x y) (macro-ratnum-make (##* p p) (##* q q)) ; already in lowest form (let* ((gcd-ps (##gcd p s)) (gcd-rq (##gcd r q)) (num (##* (##quotient p gcd-ps) (##quotient r gcd-rq))) (den (##* (##quotient q gcd-rq) (##quotient s gcd-ps)))) (if (##eq? den 1) num (macro-ratnum-make num den))))))
So, somehow, gcd-ps or gcd-rq is zero. ##ratnum.* is called only from ##*, which is the library primitive for multiplication, and ##ratnum.* is only called when one of the arguments of * is a ratnum.
The program is not big, but not small either, I can't cut and paste.
Most importantly: I don't use quotient in my code. There shoudn't have any "divide by zero" code, else it would have crashed with other scheme implementations.