gmp problem under darwin powerpc
David Fang
fang at csl.cornell.edu
Tue Jul 31 01:56:09 CEST 2012
I encountered the exact same problem with mpc 0.9 and 1.0 vs gmp on
powerpc-darwin8. mpc-1.0 failed tpow_fr w/ segfault, and mpc-0.9 failed
tpow w/ segfault, both in the gmp library.
Here's the test case I reduced:
#include <stdio.h>
#include <gmp.h>
int
main(int argc, char* argv[]) {
mpz_t a, c, d;
mpz_init(a);
mpz_init(c);
mpz_init(d);
gmp_sscanf("-1361557493340052842492411072740030734109379096992047348105806222570353910804109974675835782368",
"%Zd", c);
gmp_sscanf("-3341269126518624074606736726131115416933391662406366285968491742946894480622233806701345034010",
"%Zd", d);
gmp_printf("a = %Zd\n", a);
gmp_printf("c = %Zd\n", c);
gmp_printf("d = %Zd\n", d);
mpz_mul (a, c, c);
gmp_printf("a = %Zd\n", a);
mpz_addmul (a, d, d); /* c^2 + d^2 */
gmp_printf("a = %Zd\n", a);
if (mpz_perfect_square_p (a)) { /* was crashing here */
printf("result: 1\n");
} else {
printf("result: 0\n");
}
mpz_clear(a);
mpz_clear(c);
mpz_clear(d);
}
I've grabbed the patch suggested by Torbjorn, and found that it fixed the
above test case for powerpc-darwin8. So thank you both for reporting and
fixing. I'll will apply this fix to the fink distribution.
Fang
> On Sat Jul 21 19:26:20 CEST 2012,
Torbjorn Granlund wrote:
>> It turned out this was simple to fix. I pushed a change to both the
>> gmp-5.0 repo and the mainline repo.
>>
>> It was a register clobbering issue affecting PIC builds on ELF and
>> Darwin system, making operands of >= 20 words get an incorrect loop trip
>> count.
>>
>> If you pull the new file, your builds should work again without te speed
>> degradation resulted from removing the offending file. If you do this,
>> please send feedback to this list.
>
> Glad that it was easier to fix than expected. The 'e' program (see previous e-mail)
> is OK now (since a is not a square).
>
> % ./e
> a=13017918183496977133775209079164003070786863049686786465873731362497345253379866083852810820103005813030391929785402872601518953148250859762321945896609724349178326747526622443454716367524
> ret=0
> %
>
> Also OK is now the mpc-1.0.0rc1 testsuite for the powerpc-apple-darwin9.8.0 architecture.
>
> Thank you for your time,
>
> Regards,
>
> Denis Excoffier.
> _______________________________________________
> gmp-bugs mailing list
> gmp-bugs at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-bugs
>
--
David Fang
http://www.csl.cornell.edu/~fang/
http://www.achronix.com/
More information about the gmp-bugs
mailing list