Thomas D. Dean on Tue, 04 Dec 2012 01:36:50 +0100


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

Re: bug in PARI/GP (Segmentation Fault)


A gdb examle

>gcc -g chk.gp.c -o chk.gp -lpari
>gdb chk.gp
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/tomdean/Math/Pari/work/chk.gp...done.
(gdb) b main
Breakpoint 1 at 0x400c3f: file chk.gp.c, line 44.
(gdb) r
Starting program: /home/tomdean/Math/Pari/work/chk.gp

Breakpoint 1, main () at chk.gp.c:44
44      printf("Hello\n");
(gdb) l
39      }
40
41
42      int main(void)
43      {
44      printf("Hello\n");
45      pari_init(1000000,2);
46      GEN A;
47      func(A);
48      pari_close();
(gdb) l
49      return 0;
50      }
(gdb) n
Hello
45      pari_init(1000000,2);
(gdb) n
47      func(A);
(gdb) n
[9, -36, 30; -36, 192, -180; 30, -180, 180]
[6, 0, 3; 0, 12, 0; 0, 0, 30]
48      pari_close();
(gdb) n
49      return 0;
(gdb) n
50      }

Alternately, you could step into function A
> gdb chk.gp
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/tomdean/Math/Pari/work/chk.gp...done.
(gdb) b main
Breakpoint 1 at 0x400c3f: file chk.gp.c, line 44.
(gdb) r
44      printf("Hello\n");
(gdb) n
Hello
45      pari_init(1000000,2);
(gdb) n
47      func(A);
(gdb) s
func (N=0x0) at chk.gp.c:22
22        p1 = cgetg(4, t_MAT);
(gdb) list
17      void
18      func(GEN N)       /* void */
19      {
20        GEN a;
21        GEN p1;         /* vec */
22        p1 = cgetg(4, t_MAT);
23        gel(p1, 1) = cgetg(4, t_COL);
24        gel(p1, 2) = cgetg(4, t_COL);
25        gel(p1, 3) = cgetg(4, t_COL);
26        gcoeff(p1, 1, 1) = stoi(9);
(gdb) l
27        gcoeff(p1, 1, 2) = stoi(-36);
28        gcoeff(p1, 1, 3) = stoi(30);
29        gcoeff(p1, 2, 1) = stoi(-36);
30        gcoeff(p1, 2, 2) = stoi(192);
31        gcoeff(p1, 2, 3) = stoi(-180);
32        gcoeff(p1, 3, 1) = stoi(30);
33        gcoeff(p1, 3, 2) = stoi(-180);
34        gcoeff(p1, 3, 3) = stoi(180);
35        a = p1;
36        pari_printf("%Ps\n", a);
(gdb) n
23        gel(p1, 1) = cgetg(4, t_COL);
(gdb) n
24        gel(p1, 2) = cgetg(4, t_COL);
(gdb) p a
$1 = (GEN) 0x7fffffffe260
(gdb) p *a
$2 = 0
(gdb) p p1
$3 = (GEN) 0x7ffff7fd5230
(gdb) p *p1
$4 = 2738188573441261572

etc.

Tom Dean