Bug#1040947: perl: readline fails to detect updated file

Eric Wong e at 80x24.org
Mon Jul 17 07:51:25 BST 2023


Niko Tyni <ntyni at debian.org> wrote:
> On Sun, Jul 16, 2023 at 11:35:49AM +0300, Niko Tyni wrote:
> > Control: forwarded -1 https://github.com/Perl/perl5/issues/21240
> > 
> > On Wed, Jul 12, 2023 at 09:17:54PM +0000, Eric Wong wrote:
> > > Package: perl
> > > Version: 5.36.0-7
> > > Severity: normal
> > > Tags: upstream
> > > 
> > > Dear Maintainer,
> > > 
> > > The `readline' op (`<FH>') no longer detects updates to file
> > > which is being written to in Perl 5.36.0 after updating to bookworm.
> > > 
> > > The attached script worked fine with Perl 5.32.1 in oldstable,
> > > both scripts show the size changing with the `-s FH' op.
> > > Same behavior on both amd64 and i386.
> > 
> > Thanks for the report.
> > 
> > This changed with
> > 
> >   https://github.com/Perl/perl5/commit/80c1f1e45e8ef8c27d170fae7ade41971fe20218
> > 
> > which went upstream in 5.37.4. We backported it for 5.36 to fix #1016369 .
> > 
> > I've forwarded it upstream as https://github.com/Perl/perl5/issues/21240
> 
> Upstream says it's a direct consequence of fixing #1016369 so
> the earlier behaviour of reading after EOF was a bug.
> 
> You need to clear the EOF flag by calling $rd->clearerr() or
> seek($rd, 0, SEEK_CUR) to get the appended lines.

+Cc Ian Jackson who reported #1016369

Bug #1016369 was reported for an issue which went unnoticed for
years (or decades, even?).  I hit this new bug within minutes of
upgrading to bookworm.

Both can be data loss bugs, but checking a log file which is
being written to by another process is a much more common
occurence than FS failures[1] (or attempting readline on a
directory (as given in the #1016369 example))

Thus I expect there's far more people negatively affected by
this bug than there were for #1016369.

Since this is Perl and TIMTOWTDI, I've never used IO::Handle->error;
instead I always check defined-ness on each critical return value and
also enable Perl warnings to catch undefined return values.
I've never used `eof' checks, either; checking `chomp' result
can ensure proper termination of lines to detect truncated reads.

When there's hardware (or network FS) failure; errors tend to
get very loud anyways with the system becoming unusable, console
spew, read-only remount, etc; so the error checking done via
Perl is often redundant in that case.


[1] yes, my early (by my standards) upgrade to bookworm was triggered
    by an SSD failure, but SSD failures aren't a common occurence
    compared to tailing a log file.




More information about the Perl-maintainers mailing list