Skip to content

IO::Handle::clearerr leaves EOF state latched after file growth #1922

Closed

Description

@fglock

Summary

IO::Handle::clearerr clears $! but does not clear the EOF/read-ahead state held by a file channel. If a file grows after a read reaches EOF, a subsequent read after clearerr still returns undef in PerlOnJava.

This caused the Log::Procmail 0.14 CPAN regression in run 20261029-112411: t/20abstract.t dies at line 121 after reading a line appended to a log file. The archived system Perl 5.42.2 run passed all 281 tests. PerlOnJava failed the same assertion on both JVM and interpreter backends. The last recorded passing CPAN run was 2026-10-07 at 66b868f89.

Minimal reproducer

use File::Temp qw(tempfile);
use IO::File;
my ($writer, $path) = tempfile();
print {$writer} "first\n";
close $writer;
my $reader = IO::File->new($path, 'r') or die $!;
<$reader>;
<$reader>; # reach EOF
open $writer, '>>', $path or die $!;
print {$writer} "second\n";
close $writer;
$reader->clearerr;
my $line = <$reader>;
print defined($line) ? $line : "undef\n";

Standard Perl prints second. PerlOnJava prints undef on both backends.

Expected behavior

After clearerr, a read from a file that has grown since EOF should be able to consume the newly appended data. clearerr should clear the relevant underlying EOF/read-ahead state as well as $!.

Environment and evidence

  • Archived CPAN run: 20261029-112411, distribution Log-Procmail-0.14
  • Failing test: t/20abstract.t, line 121; 1/9 test programs failed, 0/261 reported subtests failed
  • System Perl oracle: Perl 5.42.2, all 9 programs and 281 tests passed
  • PerlOnJava: both JVM and interpreter fail at the same test
  • Reproduced on macOS 26.7.1 with OpenJDK 24.0.2; current checkout source commit a5bb374b6
  • Root cause evidence: IO::Handle::_clearerr only clears $!; CustomFileChannel retains physicalEof/isEOF and buffered read state

Activity

  1. added
    bugSomething isn't working
    area:runtimeCore Perl runtime semantics
    area:ioFiles handles paths and networking
    on Oct 29, 2026
  2. fglock commented on Oct 29, 2026

    @fglock
    OwnerAuthor

    State: released
    Agent/session: Codex root / 2026-10-29 issue-1922
    Scope: #1922, fix IO::Handle::clearerr EOF state after file growth. Per the user's follow-up, PR #1924 also includes a separate exact-integer unpack checksum fix discovered in op/pack.t.
    Work: fix/io-clearerr-eof-after-growth, published source 068dd3a49a02a4bf725115893ea78cfc15979011, draft PR #1924
    Checkpoint: 2026-10-29 UTC; the clearerr path resets EOF/read-ahead state through file-handle wrappers. The same PR preserves exact wide integer checksum sums and removes the incorrect 63-bit Q adjustment. PR #1924 is open, based on master b6546aba3c82e53642ca01b25ffdf2658cb32bb5, and GitHub reports it mergeable.
    Evidence: CPAN run 20261029-112411; Log-Procmail 0.14 passes all 281 tests with PerlOnJava. nice -n 19 make passes on the final candidate. The focused pack regression passes on JVM and interpreter; perl5_t/t/op/pack.t passes 14,726/14,726 assertions. System Perl focused reproducers pass for 54-bit/63-bit c and 63-bit Q checksums. make check-links passed for the documentation update.
    Blocked by: none
    Next: await PR #1924 review and CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ioFiles handles paths and networkingarea:runtimeCore Perl runtime semanticsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions