bug-gmp
[Top][All Lists]
Advanced

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

Re: allocation problems


From: Kevin Ryde
Subject: Re: allocation problems
Date: 29 Mar 2001 07:23:19 +1000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.5

Paul Brannan <address@hidden> writes:
>
> It seems that when gmp cannot get enough memory, it will crash.

Well, it shouldn't crash as such, but being out of memory is an
unrecoverable error.

> 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.

No functions check whether allocation was successful, all assume that
__gmp_allocate_func etc will succeed.

> Thus, when specifying a custom allocate function, one must NOT
> return null from the allocate function if there is no memory
> available.

Yes, that's so.  The next release will have the following few words to
clarify that:

       Note that no error return is allowed from these functions.  They
    must perform the specified operation, or take their own fatal
    error action (possibly after attempting a garbage collect or
    whatever).  Getting a different fatal error action is one good use
    for setting new allocation functions.

> 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.

If you mean the part

       Some applications might want to allocate memory in other ways,
    or might not want a fatal error when there is no more memory
    available.

then yes, thanks, that's a bit misleading.  We'll reword that so as
not to suggest a fatal error is avoidable.



reply via email to

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