Gerhard Niklasch on Tue, 30 Jun 1998 02:21:30 +0200


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

Re: SEGV in 2.0.9 on Solaris 2.5.1


Still re
> Message-Id: <19980629153320.G16049@io.txc.com>
> Date:         Mon, 29 Jun 1998 21:33:20 +0200
> From: Igor Schein <igor@txc.com>
> 
> Hi, the following causes a SEGV:
> % echo '2^2^26' | gp-dyn -q > /dev/null
>   ***   segmentation fault: bug in GP (please report).

My previous patch was `fixing' the wrong thing, here's a more appropriate
one.

I'm afraid though that more booboos of the same kind might be lurking
in the code, never triggered unless the PARI stack happens to straddle
the most unfortunate addresses (0 or 0x8000...00).  Waiting for Karim
to return from Bordeaux to Orsay to shed further light on this.

(Igor, the below is a bit better than what you already have -- in
particular, it gets rid of my stupid extra subtraction to recover
x from avma and z.  Besides, there was a type mismatch for checkmemory()
when building with -g... ooops, my oversight.)

Kudos to Igor for nailing this and testing out my attempted fixes.

Enjoy, Gerhard

bash$ diff -u src/kernel/none/level1.h.orig src/kernel/none/level1.h
--- src/kernel/none/level1.h.orig	Mon Jun 29 22:24:14 1998
+++ src/kernel/none/level1.h	Tue Jun 30 02:19:45 1998
@@ -92,11 +92,11 @@
 #  ifndef __M68K__
 
 #    ifdef MEMSTEP
-       void checkmemory(long z); /* in init.c */
+       void checkmemory(long x); /* in init.c */
 #    else
-#      define checkmemory(z) if (z<bot) err(errpile); avma=z;
+#      define checkmemory(x) if ((ulong)(x)>avma-bot) err(errpile);
 #    endif
-#    define new_chunk(x) (((GEN) avma) - x)
+#    define new_chunk(x) (((GEN) avma) - (x))
 
 INLINE GEN
 cgetg(long x, long y)
@@ -104,7 +104,7 @@
   const GEN z = new_chunk(x);
 
   checkwin32ctrlc;
-  checkmemory((ulong)z);
+  checkmemory(x); avma = z;
   z[0]=evaltyp(y) | evallg(x);
   return z;
 }
@@ -115,7 +115,7 @@
   const GEN z = new_chunk(x);
 
   checkwin32ctrlc;
-  checkmemory((ulong)z);
+  checkmemory(x); avma = z;
   z[0] = evaltyp(t_INT) | evallg(x);
   return z;
 }
@@ -126,7 +126,7 @@
   const GEN z = new_chunk(x);
 
   checkwin32ctrlc;
-  checkmemory((ulong)z);
+  checkmemory(x); avma = z;
   z[0] = evaltyp(t_REAL) | evallg(x);
   return z;
 }

bash$ diff -u src/language/init.c.19980628 src/language/init.c
--- src/language/init.c.19980628	Mon Jun 29 22:25:09 1998
+++ src/language/init.c	Tue Jun 30 02:16:17 1998
@@ -1013,9 +1013,10 @@
 
 #ifdef MEMSTEP
 void
-checkmemory(long z)
+checkmemory(long x)
 {
-  if (z<bot) err(errpile);
+  ulong z = avma - x;
+  if ((ulong)x > avma - bot) err(errpile);
   if (DEBUGMEM)
   {
     if (memused > z+MEMSTEP)
@@ -1030,7 +1031,6 @@
     }
     else if (memused < avma) memused=avma;
   }
-  avma=z;
 }
 #endif