Jeroen Demeyer on Wed, 10 Jun 2015 11:28:11 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Collect garbage in qfgaussred() |
Hello,While using qfgaussred(), I noticed that it can easily overflow the stack for moderate input. This is because there is no gerepile...() in the main loop. I attach a trivial patch to fix this.
Cheers, Jeroen.
commit c19b216495708e219b9216b36101ed6c3b493892 Author: Jeroen Demeyer <jdemeyer@cage.ugent.be> Date: Wed Jun 10 11:15:05 2015 +0200 Collect garbage in qfgaussred() diff --git a/src/basemath/alglin2.c b/src/basemath/alglin2.c index 3878f79..09cd1f0 100644 --- a/src/basemath/alglin2.c +++ b/src/basemath/alglin2.c @@ -1523,6 +1523,11 @@ gaussred(GEN a, long signature) gcoeff(a,i,j) = gsub(gcoeff(a,i,j), gmul(c,gcoeff(a,k,j))); } gcoeff(a,k,k) = p; + if (gc_needed(av1,1)) + { + if(DEBUGMEM>1) pari_warn(warnmem,"gaussred (t = %ld)", t); + a = gerepilecopy(av1, a); + } } else { /* all remaining diagonal coeffs are currently 0 */