Bill Allombert on Fri, 07 May 2021 18:34:25 +0200


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

Re: Pari captures my segmentation faults


On Fri, May 07, 2021 at 06:11:50PM +0200, Andreas Enge wrote:
> Hello,
> 
> the following programme exits with an error message
>   ***   bug in PARI/GP (Segmentation Fault), please report.  ***   Error in the PARI system. End of program.
> 
> #include <pari/pari.h>
> void main () {
>    int *k;
>    pari_init (500000, 0);
>    k[5] = 1;
> }
> 
> Notice that PARI somehow captures and claims for itself a segmentation
> fault that has nothing to do with it, which makes debugging complicated.
> Can this be avoided by initialising PARI differently? If not, this looks
> like a bug to me.

PARI catches signal by default, including SIGSEGV.

You can disable this by using pari_init_opts without INIT_SIGm, as in
pari_init_opts(parisize, maxprime, INIT_JMPm | INIT_DFTm);

When a SIGSEGV is caught, there is no way for PARI to know what caused
it. The only way to do what you want is to call sigaction to disable
the signal handler when not running PARI code and reenable it afterward,
but this might not be practical.

Cheers,
Bill.