[MLton] Re: [Haskell-cafe] fastest Fibonacci numbers in the West

Matthew Fluet fluet@cs.cornell.edu
Thu, 27 Jan 2005 12:27:10 -0500 (EST)


> In fact, my suspicion (unverified) is a bug in libgmp's conversion to base
> 10 during the output phase. This is a very hard thing to do well. My
> reasoning is that the program takes longer as you grow the number beyond 
> the crash point, but always segfaults before output.

I can confirm that the problem is somewhere in the IntInf.toString 
conversion:

bash-2.05b$ ./fib 19999999 > outA
Starting william_fib of n
Finished william_fib of n
Starting wesley_fib of n
Finished wesley_fib of n
william_fib and wesley_fib agree
Starting IntInf.toString of william_f_n
Finished IntInf.toString of william_f_n
Starting IntInf.toString of wesley_f_n
Finished IntInf.toString of wesley_f_n
Starting print of william_f_n_str
Finished print of william_f_n_str
Starting print of wesley_f_n_str
Finished print of wesley_f_n_str

bash-2.05b$ ./fib 25999999 > outB
Starting william_fib of n
Finished william_fib of n
Starting wesley_fib of n
Finished wesley_fib of n
william_fib and wesley_fib agree
Starting IntInf.toString of william_f_n
Segmentation fault

Furthermore, running under gdb, I get:

Program received signal SIGSEGV, Segmentation fault.
0x4004a13e in __gmpn_tdiv_qr () from /usr/lib/libgmp.so.3

So, it appears to be down deep in GnuMP.