Bill Allombert on Sun, 14 Nov 1999 19:54:15 +0100 (MET)


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

Re: subtraction bug


gp> 1+O(x)
%1 = 1 + O(x)
gp> %-%
  ***   significant pointers are lost in gerepile !!! (please report)

The bug was caused by incorrect garbage collection.
This bug is very old, but previous versions did not complain.
Strange...

I like very much manual garbage collection, but it leads to very
subtle bugs. Nobody's perfect.

Bill.
(CVS version updated)
Index: src/basemath/gen1.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/basemath/gen1.c,v
retrieving revision 1.9
diff -u -r1.9 gen1.c
--- src/basemath/gen1.c 1999/11/13 13:47:27     1.9
+++ src/basemath/gen1.c 1999/11/14 18:42:51
@@ -625,6 +625,7 @@
           lx = lg(x);
           ly = signe(y)? lg(y): 2;
          ly += l; if (lx<ly) ly=lx;
+         av = avma;
           z=cgetg(ly,t_SER);
          if (l)
          {
@@ -639,7 +640,7 @@
          }
           if (ly>2)
           {
-            l=avma;
+            tetpil = avma;
             for (i=2; i<ly; i++)
             {
               p1 = gadd((GEN)x[i],(GEN)y[i]);
@@ -652,9 +653,10 @@
                   z[j-l]=ladd((GEN)x[j],(GEN)y[j]);
                 z[2]=(long)p1; return z;
               }
-              avma=l;
+              avma = tetpil;
             }
           }
+          avma = av;
           return zeroser(vx,ly-2+valp(y));

        case t_RFRAC: case t_RFRACN: