mpz_mul memory allocation bug

Daniel Kochmański dkochmanski at
Thu Jun 25 09:32:46 UTC 2015


I've encontered problem with GMP 6.0.0 when used with ECL (Embeddable
Common-Lisp). Memory is managed by bdwgc and gmp seems to allocate
memory somewhere, where it shouldn't, resulting in:

  (SIGABRT) "Duplicate large block deallocation"

Problem is absent in GMP 4.2.1. After tracking problem, I've came to
conclusion, that it is caused by `mpn_fft_mul', which is called by
`mpn_sqr', being optimization for corner-case, when `mpz_mul' is called
with the same bignum as second and third argument.

Removing optimization "fixes" problem. `mpn_fft_mul' is called, when
size n isn't below `SQR_FFT_THRESHOLD', and comment:

  /* The current FFT code allocates its own space.  That should probably
     change.  */

might be a clue, that this is a place of problem.

Best regards,

Daniel Kochmański | Poznań, Poland
;; aka jackdaniel

"Be the change that you wish to see in the world." - Mahatma Gandhi

More information about the gmp-bugs mailing list