Karim BELABAS on Fri, 7 Jan 2000 13:21:24 +0100 (MET)


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

Re: zeta/ploth bug


[Igor:]
> ? ploth(x=-5,-4.99,real(zeta(x*I+x^2+x^3)))
> [-5.000000000000000000000000000, -4.990000000000000213162820728, 6.497774210233059296627777801 E79, 4.946657447140776084782559651 E80]
> ?   ***   bug in GP (Segmentation Fault), please report
>   ***   bug in GP (Segmentation Fault), please report
> 
> At this point the session is badly corrupted and has to be killed.

An interesting bug. There was a buffer overflow when creating a label larger
than 10^16 (for the bounding box). In fact, I tried the X-Windows version
(default) and the worse things (infinite sequence of SIGBUS and SIGSEGV)
happened in a forked process. So killing the original GP wasn't enough: I had
to kill the underlying terminal...

I changed the format specification so that only 5 significant digits are
given. This is arbitrary, but since the precise coordinates are part of the
return value, I don't think there's a need for higher precision there.

  Karim.

Index: src/graph/plotport.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/graph/plotport.c,v
retrieving revision 1.5
diff -c -r1.5 plotport.c
*** src/graph/plotport.c	1999/12/03 18:10:46	1.5
--- src/graph/plotport.c	2000/01/07 12:12:50
***************
*** 1563,1570 ****
    {
      char c1[16],c2[16],c3[16],c4[16];
  
!     sprintf(c1,"%5.3f",ybig); sprintf(c2,"%5.3f",ysml);
!     sprintf(c3,"%5.3f",xsml); sprintf(c4,"%5.3f",xbig);
  
      rectlinetype(stringrect,-2); /* Frame */
      current_color[stringrect]=BLACK;
--- 1563,1570 ----
    {
      char c1[16],c2[16],c3[16],c4[16];
  
!     sprintf(c1,"%.5g",ybig); sprintf(c2,"%.5g",ysml);
!     sprintf(c3,"%.5g",xsml); sprintf(c4,"%.5g",xbig);
  
      rectlinetype(stringrect,-2); /* Frame */
      current_color[stringrect]=BLACK;
__
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://hasse.mathematik.tu-muenchen.de/ntsw/pari/