Bill Allombert on Thu, 12 Feb 2015 20:58:26 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: PARI_stack_check false positives


On Thu, Feb 12, 2015 at 08:30:01PM +0100, Jeroen Demeyer wrote:
> Hello pari-dev,
> 
> the PARI_stack_limit functionality can sometimes lead to false
> positives: PARI assumes that the stack is essentially empty when
> pari_init_opts() is called, that there is only one stack, that
> getrlimit(RLIMIT_STACK) is constant. These assumptions are not
> necessarily true.

I suggest you read the documentation of the function
pari_stackcheck_init().

> In particular I received a report from John Cremona who was running
> Sage in a multi-threaded application. Then each thread has its own
> stack causing failures in the PARI_stack_limit checking. Note that
> PARI was not compiled with thread-local storage.

If PARI is compiled with thread-local storage, the threads that did not run
pari_init() will keep the default PARI_stack_limit value which is NULL, so the
PARI_stack_limit is automatically disabled in threads.

If PARI is compiled without thread-local storage, and a thread that did not run
pari_init() execute some PARI code, then the thread need to call
pari_stackcheck_init(). However, in this situation, there can be only one
thread using the PARI system at a time, so it is safer to restrict the use of
PARI to the thread that called pari_init() (and so calling
pari_stackcheck_init() is not needed).

Cheers,
Bill