Ciao,
Il 2020-09-03 19:22 ni...@lysator.liu.se ha scritto:
Mustafa Mohamad <mu...@outlook.com> writes:
Currently GMP aborts which sends SIGBART and forcibly aborts Julia or
any linked program. With the above patch, GMP will instead throw a
__GMP_ALLOC_OVERFLOW_FUNC
Instead of forcibly aborting
Hi, I understand aborting may be undesirable, but can you provide a bit
more context. How do you handle the callback on overflow? If you
longjmp
out, how do you arrange so that your mpz variables are in a consistent
state?
I believe that a "safe" mpz type, is anyway difficult to obtain. We may
say that if the result is outside of the range supported by mpz, the
behavior is undefined.
Try the following code on a Linux or BSD system.
int
main (int argc, char *argv[])
{
unsigned long b, e;
mpz_t p;
mpz_init (p);
b = 1;
b <<= 24;
e = ~0UL / 24 + 1;
mpz_ui_pow_ui (p, b, e);
gmp_printf ("%lu ^ %lu = %Zd", b, e, p);
mpz_clear (p);
return 0;
}
With ABI=64 I get:
16777216 ^ 768614336404564651 = 256
With ABI=32 I get:
16777216 ^ 178956971 = 256
Not a signal, nor an abort, simply an incorrect result :-)
Anyway this patch might be a way to give a little bit more control to
the programs using the library...
Ĝis,
m
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs