Gerhard Niklasch on Mon, 29 Jun 1998 22:35:33 +0200


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

Re: SEGV in 2.0.9 on Solaris 2.5.1


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).
> %

And more importantly, would the following by any chance fix it?
(If you haven't compiled for debugging, only the first hunk would
be relevant, if you have, only the second.  Line numbers in the
second may be off a little -- by not more than 3, I should hope --
because my version of init.c has already evolved some way towards
2.0.10.  In an emergency, find the function checkmemory() in
src/language/init.c and edit it in by hand.)

If it does fix it, then this was one rather hard-to-(re)produce
bug, because triggering it would have ultimately depended on the
bit patterns of pointers returned by malloc(), and those would
vary wildly among machines and libc's... the fix seems to be needed
anyway, since it is clear that the old code _could_ trip up for
this reason in the right sort of circumstances.

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	Mon Jun 29 22:24:20 1998
@@ -94,7 +94,7 @@
 #    ifdef MEMSTEP
        void checkmemory(long z); /* in init.c */
 #    else
-#      define checkmemory(z) if (z<bot) err(errpile); avma=z;
+#      define checkmemory(z) if ((ulong)z<bot) err(errpile); avma=z;
 #    endif
 #    define new_chunk(x) (((GEN) avma) - x)
 

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	Mon Jun 29 22:26:06 1998
@@ -1015,12 +1015,13 @@
 void
 checkmemory(long z)
 {
-  if (z<bot) err(errpile);
+  const ulong x=z;
+  if (x<bot) err(errpile);
   if (DEBUGMEM)
   {
     if (memused > z+MEMSTEP)
     {
-      fprintferr("...%4.0lf Mbytes used\n",(top-z)/1048576.);
+      fprintferr("...%4.0lf Mbytes used\n",(top-x)/1048576.);
       memused=z;
     }
     else if (avma > MEMSTEP && memused < avma-MEMSTEP)