Re: Big GOTCHAs WITH forprime( ) — segfault
Ilya Zakharevich <[email protected]> Fri, 26 Jan 2024 19:08:38 -0800
| Newsgroups | gmane.comp.mathematics.pari.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jan 25, 2024 at 03:12:37PM +0100, Bill Allombert wrote: > So it seems the first bad commit is > > commit a286058de199e0477bb51d82a3f092ca71a47ad9 > Author: Karim Belabas <[email protected]> > Date: Mon May 26 11:56:00 2014 +0200 > > 25- (gp -p N) or (primelimit=N in gprc_ for N >= 436273290 resulted in an > incorrect primetable. N.B. Such commands are now useless: needed primes > are produced dynamically anyway. > the "obvious" fix is > > - NEXT_PRIME_VIADIFF(p, d); /* starts at p = 3 */ > + NEXT_PRIME_VIADIFF_CHECK(p, d); /* starts at p = 3 */ > > which leads to No, I think this ends the sieving too early (or has a potential to do so). (And adds an extra conditional in the tight loop. — Though this may be not THAT important nowadays…) The “more” obvious fix is: • Make PARI know (and REPORT!) the correct primelimit; • Fix the code which decides whether to call this function. The current logic is not able to detect hitting the last known prime — so one should plan to stop at last␣known␣prime^2-1. Hope this helps, Ilya