Karim Belabas on Thu, 19 May 2016 21:37:28 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: GMP memory allocation and Macaulay2 |
* Doug Torrance [2016-05-19 20:58]: > 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. > > Currently, Macaulay2 builds its own GMP (actually MPIR, a drop-in > replacement) in which mp_set_memory_functions() does nothing. This is not > ideal, however. For example, this is the main problem keeping Macaulay2 out > of Debian, as it cannot be built with the current Debian GMP and PARI > packages. (See [1] for some discussion on this matter.) > > Would it be possible to remove the calls to mp_set_memory_functions() from > PARI? We can provide an additional flag in pari_init_opts()'s init_opts bitmask then use something like if (!(init_opts & INIT_noKERNEL_INITm)) pari_kernel_init(); in there. And similarly in pari_close_opts. You'd juste have to replace your pari_init() call by pari_init_opts(..,.., ..|INIT_noKERNEL_INITm) (or add the INIT_noKERNEL_INITm bit to your existing pari_init_opts call). I don't foresee unwanted ѕide effects *provided* you - either leave SIGINT alone and let it be fatal to the whole program, - or also replace GMP's memory allocation by a custom memory allocator that temporarily blocks BIGINT. E.g. gp sets SIGINT to stop whatever we were doing to longjmp() to gp's main loop (and present a prompt to the user); if we do that within malloc/realloc/free, we can corrupt malloc's internal state (=> crash later). You want to avoid an analogous issue. 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] `