misleading error message

marco.bodrato at tutanota.com marco.bodrato at tutanota.com
Tue Sep 24 20:13:12 CEST 2024


Ciao,

24 set 2024, 18:41 da skir at sagemath.org:

> On Tue, Sep 24, 2024 at 01:22:03PM +0200, Vincent Lefevre wrote:
>
>> So perhaps SIGFPE is the right thing for GMP after all (as this
>> could be regarded as overflow / out of range). In any case, the
>> "Floating point exception" message from the system is incorrect,
>> as SIGFPE is also generated for integer operations.
>>
>
> But I don't see why SIGFPE here is the right thing, while printing
> an error message to stderr and calling abort() (as for errors
> in the memory.c) - is not.
>

I have no particular opinion about "is it better to print a message and abort() or rising SIGFPE?".
But I think that it should be better to have a single function (eg. __gmp_exception in errno.c) called by every part of code that have to handle a critical error.
That way, those that disagree with the answer to the question above have a single file and a single function to change to adapt the library to their needs.


> BTW, description in
> https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html
> lists SIGFPE as "Erroneous arithmetic operation."  Perhaps, such message
> from the system might be even more misleading for memory-related errors.
>

Actually, the error you refer to is not "memory-related"; it's an overflow of the mpz_t type.
With the current format of that type in the library, an mpz_t variable can represent (when running in a 64-bits architecture) numbers up to 2^37 bits, not larger.

For memory-related errors (as you saw in memory.c), the library currently prints a message and calls abort().

Ĝis,
mb


More information about the gmp-discuss mailing list