Bug in GMP module?

Started by TedWalther, December 14, 2009, 02:36:14 AM

Previous topic - Next topic

TedWalther

For the last few releases, I've gotten segmentation faults on 64 bit Ubuntu and 64 bit OpenBSD.  Haven't tested on 32 bit, no hardware to test on.  Am using libgmp version 3.5.0



The bug is a segfault whenever I try to factor a non-prime number using GMP.



To duplicate the bug, do this:



(module "gmp.lsp")
(GMP:factor "4")


I narrowed the segfault down to this line of code in the push-factor function in the gmp module:



(set 'f (get-string (__gmpz_get_str rops 10 f)))
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#1
What happens when you run (test-GMP) ? I ran it fine a few months back on your OpenBSD machine, and it was fine on 64-bit, but never have tested on 64-bit UBUNTU. The test also checks the factor method.



I could check it out, but I am travelling and don't have the address of your machine with me, although I remember user-id and password. Perhaps you can email me the machine address again and I can look at it too?

TedWalther

#2

> (test-GMP)
GMP:+ -> Ok
GMP:- -> Ok
GMP:* -> Ok
GMP:/ -> Ok
GMP:% -> Ok
GMP:** -> Ok
GMP:= -> Ok
Problem in GMP:<
Problem in GMP:>
Problem in GMP:<=
Problem in GMP:>=
GMP:& -> Ok
GMP:| -> Ok
GMP:^ -> Ok
GMP:~ -> Ok
GMP:prime? -> Ok
GMP:next-prime -> Ok
Problem in GMP:factor
GMP:gcd -> Ok
GMP:bin -> Ok
GMP:fac -> Ok
GMP:fib -> Ok
GMP:seed -> Ok
"t-> Ok"
>


It didn't segfault.  Odd.



On OpenBSD, I am using libgmp.so.8.0

On Ubuntu, I am using libgmp.so.3.5.0



Exact same results of (test-GMP) for both.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#3
There is a new development/latest/newlisp-10.1.9-dev.tgz fixing gmp.lsp. Note that the fix is in both, the newLISP binary and the module file gmp.lsp. Both are sign-extension fixes for 64-bit mode. Ted: that package is already on your m4, where I tested it.

TedWalther

#4
On Ubuntu, the comparison tests now pass, but factor still bombs out on the same line of code, despite the int32's sprinkled in it.



> (test-GMP)
GMP:+ -> Ok
GMP:- -> Ok
GMP:* -> Ok
GMP:/ -> Ok
GMP:% -> Ok
GMP:** -> Ok
GMP:= -> Ok
GMP:< -> Ok
GMP:> -> Ok
GMP:<= -> Ok
GMP:>= -> Ok
GMP:& -> Ok
GMP:| -> Ok
GMP:^ -> Ok
GMP:~ -> Ok
GMP:prime? -> Ok
GMP:next-prime -> Ok
Segmentation fault
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.