Restore previous memory allocation behavior of GMP integers in ForeignFunctions package #3132
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #3124, I switched the memory allocation of
mpzT
objects (GMP integers) in theForeignFunctions
package from GMP's ownmpz_init
(with a call tompz_clear
when finalizing the pointer) to the one we use forZZ
at top level that uses GC to allocate memory. This caused Macaulay2 to crash when calling certain GMP functions using the foreign function interface.In particular, the examples were failing in Ubuntu 18.04 using GMP 6.1 (before lazy allocation was added in GMP 6.2). Even using GMP 6.2, we'd get these same crashes using large enough integers to trigger memory allocation.
In this PR, we restore the previous behavior of using
mpz_init
. We also make a few other related changes:ZZ
's that we calltoInt
on really fit inside anint
.gmp.d
that were created for #3124 that are no longer used.mpfrT
objects (MPFR reals). Until I figure out what's going on, the finalization code is commented out because otherwise we get segfaults during garbage collection.Closes: #3128