Karim Belabas on Sat, 08 Mar 2014 19:14:30 +0100


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

Re: Infinite loop in initprimes0()


* Jeroen Demeyer [2014-02-09 16:35]:
> On 2014-02-09 16:05, Bill Allombert wrote:
>>On Sun, Feb 09, 2014 at 02:48:28PM +0100, Jeroen Demeyer wrote:
>>>Dear pari-dev,
>>>
>>>When calling initprimes0(), an infinite loop is possible.
>>
>>Could you give an example ?
> 
> gp> install(initprimetable, "vL")
> gp> initprimetable(2^20)
> Segmentation fault
> 
> With the modification I suggested, this does not crash.

Indeed, I had introduced this in 8c97fae6 (Apr 11 2013), which made
major changes in the private prime table code & usage (remove support
for prime gaps > 255, make primetable read-only).

This has gone unnoticed since the gp prime table is now computed once and
for all on startup: changing primelimit from within gp is now a no-op,
in particular it no longer crashes gp when invoked within forprime()).
So the bug only affected libpari programming explicitly using initprimes
or initprimetable.

I committed your patch (then cleanup up neighbouring code again).

Thanks !

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`