Max A. on Thu, 05 Oct 2006 21:38:33 +0200


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

gp2c-run causes the PARI stack overflows


Hello!

I've tried to run the following simple gp program via gp2c / gp2c-run

for(d=89,999, print1(d," "); forstep(n=d*10^9,(d+1)*10^9,4,
if(Mod(2,n+2)^n==2,print(n," <===")) ) )

When I run this program under gp2c-run it constantly complains that
"the PARI stack overflows" even when I allocated 2GB for the stack!
(see below)
Note that the original gp program does not require much memory and
perfectly works with the default stack size.
What's wrong?

Thanks,
Max

=========
$ gp2c-run 55.gp
Reading GPRC: /etc/gprc ...Done.

                              GP/PARI CALCULATOR Version 2.4.0
(development CHANGES-1.1592)
                               amd64 running linux (x86-64/GMP-4.2.1
kernel) 64-bit version
                         compiled: Sep 15 2006, gcc-4.1.2 20060901
(prerelease) (Debian 4.1.1-13)
                                      (readline v5.1 enabled,
extended help enabled)

                                          Copyright (C) 2000-2006 The
PARI Group

PARI/GP is free software, covered by the GNU General Public License,
and comes WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500000
? allocatemem(2^31)
? init_55()
89
 *** init_55: the PARI stack overflows !
 current stack size: 2147483648 (2048.000 Mbytes)
 [hint] you can increase GP stack with allocatemem()
========

The output of gp2c is shown below:

========
/*-*- compile-command: "/usr/bin/gcc -c -o 55.gp.o -O3 -Wall
-fno-strict-aliasing -fomit-frame-pointer -fPIC -I/usr/local/include
55.gp.c && /usr/bin/gcc -o 55.gp.so -shared -O3 -Wall
-fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared 55.gp.o
-lc -ldl -lm -L/usr/local/lib -lgmp -L/usr/local/lib -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_55","vp","init_55","./55.gp.so");
*/
void init_55(long prec);
/*End of prototype*/

void
init_55(long prec)        /* void */
{
 {
   long d;
   GEN p1, p2;
   for (d = 89; d <= 999; ++d)
   {
     pariprintf("%ld ", d);
     p1 = gmulsg(d, gpowgs(stoi(10), 9));
     p2 = gmulsg(d + 1, gpowgs(stoi(10), 9));
     {
       GEN n;
       for (n = p1; gcmp(n, p2) <= 0; n = gaddgs(n, 4))
         if (gequalgs(gpow(gmodulsg(2, gaddgs(n, 2)), n, prec), 2))
           pariprintf("%Z <===\n", n);
     }
   }
 }
 return;
}

int main() {
   init_55(38);
   return 0;
}
========