[prev in list] [next in list] [prev in thread] [next in thread]
List: gmp-discuss
Subject: Patch to allow more granular aborting.
From: tg () gmplib ! org (Torbjorn Granlund)
Date: 2011-03-15 11:45:52
Message-ID: 86lj0g38un.fsf () shell ! gmplib ! org
[Download RAW message or body]
[This thread began at gmp-devel.]
Theo Schlossnagle <jesus at omniti.com> writes:
On Tuesday, March 15, 2011, Torbjorn Granlund <tg at gmplib.org> wrote:
> Theo Schlossnagle <jesus at omniti.com> writes:
>
> ??I'm confused now. ?In a previous mail, you suggested I use the builtin
> ??libgmp mechanism to replace the allocators. ?It appears libgmp indeed
> ??has replaceable allocators, but then when it goes to allocate they are
> ??not used. I results in I me being unable to wrap realloc and throw and
> ??exception on NULL return.
>
> GMP only allocates (reallocates) things when memory (more memory) is
> needed, as Niels pointed out.
>
> If you want allocation (reallocation) using the replaceable allocators
> to take place also when memory is not needed, then you probably need to
> maintain your custom GMP version.
>
> Your statement that "when [GMP] goes to allocate [the custom allocators]
> are not used" is simply a misunderstanding of GMP source code.
I call mpz_n_pow_ui. Libgmp performs an allocation directly using
mpz_realloc instead of the reallocation function I set. Therefore I
cannot change the way in which libgmp handles OOM. This is my problem.
It appears that the mpz_n_pow_ui is not the only function that behaves
this way. There is a problem.
If that is really the case, it is a bug. Please read the page in the
manual about bug reporting, and then send a report to the gmp-bugs list.
Handling these conditions from a signal handler is not portably safe.
I proposed a solution to the problem. An explanation that I simply
don't understand the source code is not helpful. Please instead
propose a solution that allows me to use the stock version of libgmp.
This problem is not unique to me. It is a problem for anyone
attempting to use libgmp in a long running process that takes user
input. (lua embed, for example)
I agree that error handling in GMP is not good. This issue has been
discussed several times on this list. Unfortunately, the C language
does not provide any good solutions to the problem. People have pointed
out why your patch does not help, I will not repeat it.
--
Torbj?rn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic