Paul van Wamelen on Tue, 23 May 2000 17:30:33 -0500 (CDT)


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

qfminim bug 2


Dear Pari developers,

In qfminim with the flag equal to 2 (that is for dealing with
non-integral coefficients), if you want no vectors returned but the
count is high so that a garbage collection is done during the count,
we get a segmentation fault:

                    GP/PARI CALCULATOR Version 2.0.19 (beta)
                 UltraSparc (MicroSparc kernel) 32-bit version
                (readline v2.2 enabled, extended help available)

                           Copyright (C) 1989-1999 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
? Qmat = [0.1121838950156262993198861903, -0.002294825170315502480266502542, -0.0003341361628152951755992730843, -0.01013912749586145381073809834, 0.02116023427426229437120984486, -0.04256500745397313843968688094; -0.002294825170315502480266502542, 0.0101
5200067110896037957565105, -0.01062142221979604038700374101, 0.02221761484223348391636273181, -0.04692817364343353260667839410, 0.09682920303695533048890485886; -0.0003341361628152951755992730843, -0.01062142221979604038700374101, 0.0232236177136219324940
5380743, -0.04916043776688522464771472577, 0.1039418432338874002700813232, -0.2172034509288058753060698920; -0.01013912749586145381073809834, 0.02221761484223348391636273181, -0.04916043776688522464771472577, 0.1063794149634527727718385934, -0.22753531414
34766490036291424, 0.4811386293014932004986704852; 0.02116023427426229437120984486, -0.04692817364343353260667839410, 0.1039418432338874002700813232, -0.2275353141434766490036291424, 0.4923171763996275063527134313, -1.053129742820247211799751080; -0.04256
500745397313843968688094, 0.09682920303695533048890485886, -0.2172034509288058753060698920, 0.4811386293014932004986704852, -1.053129742820247211799751080, 2.278649858405744971446804119];
? qfminim(Qmat*100,1,0,2)
  ***   forbidden  ***   bug in GP (Segmentation Fault), please report
? 

The reason for the bug is that when garbage collection is done the
array S is not kept if no vectors are wanted (makes sense), but the
array is returned when smallvectors returns. This is ok if no garbage
collection is done because S is initialized to the empty matrix (and
this should be returned). The patch is something like:

RCS file: /home/megrez/cvsroot/pari/src/basemath/bibli1.c,v
retrieving revision 1.25
diff -r1.25 bibli1.c
2593c2593,2594
<   S = cgetg(stockmax+1,t_MAT);
---
>   if(stockmax)
>     S = cgetg(stockmax+1,t_MAT);
2749,2750c2766,2774
<   u[2]=(long)normax1; setlg(S,stockmax+1);
<   u[3]=(long)S; return u;
---
>   u[2]=(long)normax1;
>   if(stockmax)
>   {
>     setlg(S,stockmax+1);
>     u[3]=(long)S;
>   }
>   else
>     u[3]=(long)cgetg(1,t_MAT);
>   return u;

The line numbers are slightly wrong...

Happy computing!
Paul van Wamelen