Iwao KIMURA on Wed, 02 Dec 1998 00:02:07 +0900


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

Re: A very bad bug


Hi developers,

From: Igor Schein <igor@txc.com>
Subject: A very bad bug
Date: Mon, 30 Nov 1998 17:17:16 -0500

> ? \k
>                    GP/PARI CALCULATOR Version 2.0.12 (alpha)
>                  UltraSparc (MicroSparc kernel) 32-bit version
>                 (readline enabled, extended help not available)
> 
>                            Copyright (C) 1989-1998 by
>           C. Batut, K. Belabas, D. Bernardi, H. Cohen and M. Olivier.
> 
> Type ? for help, \q to quit.
> Type ?12 for how to get moral (and possibly technical) support.
> 
>    realprecision = 28 significant digits
>    seriesprecision = 16 significant terms
>    format = g0.28
> 
> parisize = 4000000, primelimit = 500000
> ? \q
>   ***   segmentation fault: bug in GP (please report).
> 
>   ***   segmentation fault: bug in GP (please report).

This seems easy to fix:
--------------------
amaki: {197} diff -u src/gp/gp.c.orig src/gp/gp.c
--- src/gp/gp.c.orig    Tue Dec  1 23:34:53 1998
+++ src/gp/gp.c Tue Dec  1 23:35:31 1998
@@ -1214,7 +1214,7 @@
 gp_quit()
 {
   free_graph(); freeall();
-  while (bufindex) free((void *)buflist[bufindex--]);
+  while (bufindex > -2) free((void *)buflist[bufindex--]);
   if (INIT_SIG)
   {
 #ifdef SIGBUS
--------------------

The problem is, as far as I understand, bufindex is initialized by
sentinel value -1 in gp_preinit(), but this is overlooked in
gp_quit().

;#			     Iwao KIMURA			;#
;#		      Institute of Mathematics,			;#
;#		University of TSUKUBA, IBARAKI, JAPAN.		;#