abort()

Aaron Heckmann aaron.heckmann at gmail.com
Tue Nov 9 17:35:11 CET 2010


abort() is bad b/c it crashes the program, in this case a server. It would
be nice if gmp got away from abort() and instead passed back an error msg of
some sort so other programs could handle these situations gracefully.

On Mon, Nov 8, 2010 at 12:28 PM, Torbjorn Granlund <tg at gmplib.org> wrote:

> Aaron Heckmann <aaron.heckmann at gmail.com> writes:
>
>  What is the reasoning behind gmp using abort() when out of memory as
> opposed
>  to throwing an exception?
>
> Because GMP is written in C.  You can catch the signal caused by abort,
> but how to do that is system dependent.
>
>  I'm writing a binding for nodejs where aborting
>  isn't an option. Are there any work arounds?
>
>  gmp: overflow in mpz type
>  Aborted
>
> This is not an out-of-memory error, but really an overflow.  You're
> attempting to compute a result that is more than 2^31 words.  This
> behaviour cannot be changed with by using GMP's custom allocation (see
> the manual).
>
> --
> Torbjörn
>



-- 
Aaron


More information about the gmp-discuss mailing list