Bill Allombert on Mon, 06 Feb 2017 00:36:54 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Giac for Debian: test suite segfaults with pthread pari |
On Sun, Feb 05, 2017 at 06:33:00PM +0000, Ximin Luo wrote: > Ximin Luo: > > [..] > > > > In Debian pari is compiled with pthreads. To make the compilation succeed, we need to patch Giac like this: https://git.archlinux.org/svntogit/community.git/tree/trunk/giac-pari-thread.patch?h=packages/giac > > > > however I still get segfaults when running Giac's test suite. Stack thread is at the end of this email, but basically I think the reason is that > > > > src/kernel/none/level1.h:106 > > if (x > (avma-pari_mainstack->bot) / sizeof(long)) > > > > here pari_mainstack is either NULL or uninitialised. So I guess we need to add some initialisation functions to Giac, to fix this problem. But I'm not familiar with pari, so I don't know what to do here. Any help or guidance would be appreciated. > > > > [..] > > Hi, I think I have figured out how to resolve this issue, it was to do > with TLS rather than pthreads. The solution was to fix Giac to call > pari_init_opts for every new thread, instead of only once. I suggest you read the appendix B of the libpari manual: <http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.9.0/libpari.pdf> which explain how threads are supposed to be setup. It seems GIAC assumes that PARI is not MT-safe and use mutex to serialize PARI call. The patch look odd. The code below is not a good start: +#ifdef ENABLE_TLS + extern THREAD void *PARI_stack_limit; +#else extern void *PARI_stack_limit; +#endif first THREAD is defined to the empty string when ENABLE_TLS is not defined, so just extern THREAD void *PARI_stack_limit; would do. Second, there are really no need to mess with this variable when you can use pari_stackcheck_init(). Cheers, Bill.