emacs-diffs
[Top][All Lists]
Advanced

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

master ae169bd: ; Add a FIXME regarding the GMP memory allocation functi


From: Philipp Stephani
Subject: master ae169bd: ; Add a FIXME regarding the GMP memory allocation functions.
Date: Mon, 13 Dec 2021 12:29:15 -0500 (EST)

branch: master
commit ae169bda2cbec49e30a7ca15828c45f2c638e500
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    ; Add a FIXME regarding the GMP memory allocation functions.
    
    * src/bignum.c (init_bignum): Add a warning about the technically
    incorrect use of the GMP memory allocation functions.
---
 src/bignum.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/bignum.c b/src/bignum.c
index 1ac75c1..5c587fc 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -53,6 +53,15 @@ init_bignum (void)
 {
   eassert (mp_bits_per_limb == GMP_NUMB_BITS);
   integer_width = 1 << 16;
+
+  /* FIXME: The Info node `(gmp) Custom Allocation' states: "No error
+     return is allowed from any of these functions, if they return
+     then they must have performed the specified operation. [...]
+     There's currently no defined way for the allocation functions to
+     recover from an error such as out of memory, they must terminate
+     program execution.  A 'longjmp' or throwing a C++ exception will
+     have undefined results."  But xmalloc and xrealloc do call
+     'longjmp'.  */
   mp_set_memory_functions (xmalloc, xrealloc_for_gmp, xfree_for_gmp);
 
   for (int i = 0; i < ARRAYELTS (mpz); i++)



reply via email to

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