Karim Belabas on Fri, 20 May 2016 08:58:35 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: GMP memory allocation and Macaulay2 |
* Doug Torrance [2016-05-19 22:55]: > On 05/19/2016 03:59 PM, Bill Allombert wrote: > >On Thu, May 19, 2016 at 02:58:16PM -0400, Doug Torrance wrote: > >>Hello! > >> > >>Currently, PARI sets the GMP memory allocation functions in > >>pari_kernel_init(). However, this may cause problems for > >>applications which use both the PARI and GMP libraries such as > >>Macaulay2. Building Macaulay2 against unpatched GMP and PARI > >>libraries causes segmentation faults. > >You issue is related to the bug #1317. > >Do you know why the segmentation faults occurs ? This is the > >crux of the matter. > > I don't recall at the moment. I'll work on getting back to you with > a backtrace. I would guess Macaulay2 has a custom memory allocator, uses gmp at the mpz level (directly or through third party libraries, in multiple independent ways), and expects to garbage collect all objects making assumptions about the way they were allocated. And at some point they hit a gmp-via-libpari object and try to GC it using gmp-via-??? method. What Bill suggested is functionnally equivalent to what I wrote, with the added benefit of not having to patch libpari => immediate portable solution. (Thus that my caveat about SIGINT still applies !) I still think pari_init_opts() should allow disabling pari_kernel_init() in a less cumbersome way. At least it would allow us to document a recommended solution together with the caveat. Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `