Skip Menu |

This queue is for tickets about the News-Newsrc CPAN distribution.

Report information
The Basics
Id: 77603
Status: resolved
Priority: 0/
Queue: News-Newsrc

People
Owner: SWMCD [...] cpan.org
Requestors: baron [...] bologrew.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Newsrc fails with very large article counts
Date: Sun, 3 Jun 2012 17:14:38 +0100
To: bug-News-Newsrc [...] rt.cpan.org
From: Nicholas Redgrave <baron [...] bologrew.net>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Newsrc fails when writing very large article counts back to the .newsrc file. My ISP's news server has some newsgroups where the article number exceeds 2147483647. Newsrc can read large numbers but cannot write them back. Module: News-Newsrc-1.09 Perl version: perl 5, version 12, subversion 4 (v5.12.4) built for i386-linux- thread-multi OS: Linux njr 2.6.43.5-2.fc15.i686 #1 SMP Tue May 8 12:07:12 UTC 2012 i686 i686 i386 GNU/Linux The following code demonstrates the problem when rerun several times with a .newsrc as follows: fake.fail: 2147483646 fake.okay: 10000 #!/usr/bin/perl use News::Newsrc; use strict; use warnings; my $grp; my $saved_art; my @groups; # reads saved article count, increments and writes back # saving fails when article count exceeds 2147483647 # test using .newsrc as follows: #fake.fail: 2147483646 #fake.okay: 10000 #handle stored article count my $newsrc=News::Newsrc->new(); $newsrc->load(); @groups = $newsrc->groups(); foreach $grp (@groups) { print "Group: " . $grp ."\n"; #get last read article $saved_art = $newsrc->get_articles($grp); print "saved_art: " . $saved_art ."\n"; $saved_art++; #set last read article $newsrc->set_articles($grp, $saved_art); $newsrc->save(); } #end of foreach $grp (@groups) #eof A quick fix is to comment out this line in Newsrc.pm: defined $min and $min < 0 and return 0; in "sub set_articles". Best regards, Nicholas Redgrave - -- Fingerprint for GnuPG ID 0x0189562F ADCF CC73 0DFB 9613 FA78 553B C98C 086F 0189 562F -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) iD8DBQFPy413yYwIbwGJVi8RAlzWAJ91gZZ3RK6er54XkYlmJpEHcQXpLACeN/wR BThpkw1X/mO1Gg66+lNX50s= =OfLv -----END PGP SIGNATURE-----
On Sun Jun 03 12:15:02 2012, baron@bologrew.net wrote: Show quoted text
> Newsrc fails when writing very large article counts back to the > .newsrc file.
Show quoted text
> My ISP's news server has some newsgroups where the article number > exceeds 2147483647. > Newsrc can read large numbers but cannot write them back.
Urk...2147483647 is INT_MAX on 32-bit machines. /usr/include>grep INT_MAX limits.h # define INT_MAX 2147483647 The underlying problem is that Set::IntSpan does use integer; So article numbers higher than that go negative. This fix Show quoted text
> A quick fix is to comment out this line in Newsrc.pm: > > defined $min and $min < 0 and return 0; > > in "sub set_articles".
might work, but I wouldn't rely on it. A better fix would be to remove the use integer from Set::IntSpan. Then Set::IntSpan will use doubles, which have a 53-bit mantissa, which should be enough for...ummm...a long time... I put the use integer in long ago on the assumption that it would run faster. But I never benchmarked it. I'll try running some benchmarks. If it doesn't matter, I'll just remove it. If it does matter, I'll have to find a way for applications (like News::Newsrc) to selectively disable it.
Fixed in News::Newsrc 1.10 with Set::IntSpan 1.17. The underlying Set::IntSpan module no longer specifies use integer; You can get it back if you want. See the POD for details.