[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

allocation problems

From: Paul Brannan
Subject: allocation problems
Date: Wed, 28 Mar 2001 14:15:22 -0500 (EST)

It seems that when gmp cannot get enough memory, it will crash.  This is
due to a design problem in gmp.  Since the documentation does not specify
which functions may or may not allocate/reallocate memory, it is
impossible to avoid these functions that allocate memory and do not check
to see if memory was properly allocated.  Thus, when specifying a custom
allocate function, one must NOT return null from the allocate function if
there is no memory available.

The documentation DOES state that one can avoid a fatal error by using
custom allocation functions, but there is no way to inform the caller that
memory allocation failed.  It is not acceptable for the custom allocation
functions to block.

Possible solutions:

  1) check for null pointers any time a pointer has not yet been checked
  2) Fix the documentation so that we can avoid functions that use
     unchecked pointers, and provide a documented way to make sure that
     the init functions succeeded (checking _mp_d is undocumented, so
     there is no guarantee this will work between releases)

Paul Brannan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]