Ruhma Tahir on Mon, 03 Dec 2012 22:00:46 +0100


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

bug in PARI/GP (Segmentation Fault)


Hi,

I get the following error at run time when i run my C code which uses pari library:-

***   bug in PARI/GP (Segmentation Fault), please report
  ***   Error in the PARI system. End of program.

I got the C code by running gp2c on the following simple gp script:-

func(N) =
{
my(a = [9, -36, 30; -36, 192, -180; 30, -180, 180]);
print(a);
print(mathnf(a));
}


The C code returned by gp2c is following:-

/*-*- compile-command: "/usr/bin/gcc -c -o hnf.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I"/usr/local/include" hnf.gp.c && /usr/bin/gcc -o hnf.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared hnf.gp.o -lc -lm -L/usr/local/lib -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_hnf","v","init_hnf","./hnf.gp.so");
GP;install("func","vD0,G,","func","./hnf.gp.so");
*/
void init_hnf(void);
void func(GEN N);
/*End of prototype*/

void
init_hnf(void)  /* void */
{
  return;
}

void
func(GEN N)  /* void */
{
  GEN a;
  GEN p1;  /* vec */
  p1 = cgetg(4, t_MAT);
  gel(p1, 1) = cgetg(4, t_COL);
  gel(p1, 2) = cgetg(4, t_COL);
  gel(p1, 3) = cgetg(4, t_COL);
  gcoeff(p1, 1, 1) = stoi(9);
  gcoeff(p1, 1, 2) = stoi(-36);
  gcoeff(p1, 1, 3) = stoi(30);
  gcoeff(p1, 2, 1) = stoi(-36);
  gcoeff(p1, 2, 2) = stoi(192);
  gcoeff(p1, 2, 3) = stoi(-180);
  gcoeff(p1, 3, 1) = stoi(30);
  gcoeff(p1, 3, 2) = stoi(-180);
  gcoeff(p1, 3, 3) = stoi(180);
  a = p1;
  pari_printf("%Ps\n", a);
  pari_printf("%Ps\n", mathnf0(a, 0));
}

int main(void)
{
printf("Hello\n");
pari_init(1000000,2);
GEN A;
func(A);
pari_close();
return 0;
}

Any help to fix this issue will be highly highly appreciated ..... thanks a lot in advance

--
Regards,
Ruhma Tahir