Bill Allombert on Sun, 19 Feb 2023 19:23:52 +0100


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

Re: Segmentation Fault in Pari/GP from gp2c-run


On Sun, Feb 19, 2023 at 05:58:12PM +0100, Bill Allombert wrote:
> On Sun, Feb 19, 2023 at 07:57:32AM -0800, Edmond Griffin wrote:
> > Hello,
> > 
> >     I am working on an old conjecture of Erdos-Turan using Pari/GP.  Although the computations are simple, the number of them is very large.  To speed things up, I hoped to convert my .gp code into C using gp2c. I am having difficulty doing so.
> > 
> >    I believe both gp and gp2c were built successfully on my machine - a quad core i7 MacBook Pro.  When I compile and run the code using gp2c-run I get no warnings of undeclared or unused variables.  I do get the following warning before gp starts:
> > 
> > ld: warning: -undefined dynamic_lookup may not work with chained fixups
> > 
> > 
> >    Then when I call my function (extDnkc) I get
> > 
> > ? extDnkc(15,6,0,"/Volumes/BinPolyData/Diffs/")    
> >   ***   user warning: 
> >   ***   at top-level: extDnkc(15,6,0,"/Volumes/BinPolyData/Diffs/")
> >   ***                 ^---------------------------------------------
> >   *** extDnkc: bug in PARI/GP (Segmentation Fault), please report.
> > 
> > 
> > Can you suggest a course of action?
> >     fName = strjoin([fPath,strprintf("D_%d_%d_TN.csv", n, k)]);
> >     iferr(fIn=fileopen(fName,"r"), ERR, 
> >         warning(strprintf("Bad input file: %s",fName)); return,errname(ERR)=="e_FILE");
> 
> Indeed, there is a bug in PARI that cause warning() to be miscompiled by gp2c.
> I suggest to replace warning() by print() until we fix it.
> Sorry for the trouble!

If you are willing to rebuild both pari and gp2c to fix this issue, in
the PARI file 'src/functions/programming/warning' replaces the line
 (?gen,...):void  pari_warn(warnuser, "${2 format_string}"${2 format_args})
by
 (gen,...):void  pari_warn(warnuser, mkvecn($#, $2))
(with a leading space), or just remove it.

This is fixed in the GIT commit 1495659ef3eb71072f392a5e1adbd4264bc4d466
in the master branch.
Thanks for reporting this issue!

Cheers,
Bill