Error handler for GMP?

Marco Bodrato bodrato at mail.dm.unipi.it
Tue Feb 1 11:22:00 CET 2022


Ciao,

Il 2021-06-12 16:49 Marco Bodrato ha scritto:
> Anyway, for internal coherence, I think that we should at least check
> that all the functions in the library that might "abort" do this using
> an "exception". For this, I propose the attached patch.

That patch ("Handle overflow in mpz_type through errno") was pushed.

We still have at least two functions directly using an abort():
__gmp_exception, and __gmp_invalid_operation.

They live in two different files (errno.c and invalid.c respectively), 
that handle somehow differently how to rise() a signal. The first checks 
#ifdef SIGFPE, the second depends on #if HAVE_UNISTD_H, and #if ! 
HAVE_RAISE.

I'm tempted to remove the file invalid.c, and to keep errno.c only, with 
the function __gmp_invalid_operation() calling __gmp_exception as all 
the other exceptions do. Of course with a new 
GMP_ERROR_INVALID_FLOAT_OPERATION = 32 constant.

Any comment?


En passant: the previous patch removed the message printed to stderr. 
Should we recover it using the following?

void
__gmp_overflow_in_mpz (void)
{
   fprintf (stderr, "gmp: overflow in mpz type\n"); /*This line added.*/
   __gmp_exception (GMP_ERROR_MPZ_OVERFLOW);
}

Should we print a message also for the other exceptions in errno.c?

Ĝis,
m


More information about the gmp-devel mailing list