[CPAN] File-Data 1.20 loses a live file lock during hash construction
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the overlapping RuntimeIO and glob ownership paths, coordinating with the active migration in #2043 and avoiding the cleanup changes under PR #1938. Read the ownership and cleanup flow through IOOperator and CustomFileChannel, then add the project-owned inline hash literal regression. Done means the test passes on both PerlOnJava backends, the upstream t/test.t passes on both, and abandoned handles are still cleaned up after their final Perl-visible owner is released.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
File-Data-1.20 fails its locked test on PerlOnJava. A shared-locked read handle becomes unlocked while the test constructs a hash of File::Data objects from inline constructor calls. A second read/write open then succeeds, although the original object remains stored in the hash.
This is a PerlOnJava IO ownership/lifetime bug exposed by CPAN, not a File::Data port or native dependency failure. A direct flock probe behaves correctly, and building the same objects in named variables before inserting them into the hash preserves the lock.
Reproducer
Run from the extracted File-Data-1.20 distribution, with its t/read and t/write fixtures:
use File::Data;
my %file = (
read => File::Data->new('./t/read', 'ro'),
write => File::Data->new('./t/write'),
);
# The upstream test expects this open to fail while $file{read} is alive.
my $again = File::Data->new($file{read}->_var('filename'));
die "read lock was lost" if $again;
System Perl leaves $again undefined. PerlOnJava returns another File::Data object. If the two constructor results are first assigned to named variables and those variables are then placed in %file, the reopen is blocked as expected.
Evidence
- Distribution:
File-Data-1.20(pure Perl). - CPAN random run:
20261115-091204-23477. - Upstream failure:
t/test.t, test 3 of 16 (locked, line 69); the other 15 tests pass. - System Perl 5.42.2 on macOS:
prove -v t/test.tpasses all 16 tests. - PerlOnJava source
455ff0acc3a0872b04b8b870aa1f9ac85984a764, Perl 5.44.1, Java 24.0.2, macOS Darwin 25.6.0 arm64: the upstream test and the reduced hash-construction reproducer fail on both JVM and interpreter backends. - Constructing the objects in named variables before hash insertion passes the lock check on both PerlOnJava backends. A direct shared-then-exclusive
flockprobe also returns the expected blocked result.
Root cause
Anonymous filehandle globs are registered for phantom-reference cleanup in IOOperator. Opening another file assigns a descriptor and processes abandoned globs in RuntimeIO; closing one releases its lock in CustomFileChannel. In the inline hash-literal case, the first handle is staged while the next constructor opens its file, and the cleanup path treats that still-live source-level temporary as abandoned. The hash ends up holding the File::Data object after its underlying handle has already been closed.
The ownership gap is in preserving the anonymous glob/IO across the intermediate list used to build the hash literal. The failing behavior is shared by both backends.
Related work and dependency
- Blocked by #2043: its active ownership migration replaces reachability-based lifecycle decisions in the overlapping
RuntimeIO/glob paths. Coordinate the fix with that work; do not independently replace the cleanup mechanism while PR #1938 is changing it. - Related to #2037: that separately tracked
Archive::Anyfailure also exposes IO/object lifetime loss and is deferred until #2043 lands. It has its own reproducer and acceptance criteria.
Acceptance criteria
- Add a project-owned regression for an inline hash literal that retains both filehandle objects while the second file is opened.
- Validate the regression with standard Perl first, then on PerlOnJava JVM and interpreter backends.
- Make
File-Data-1.20t/test.tpass on both PerlOnJava backends. - Keep abandoned-handle cleanup working after the final Perl-visible owner is released; a live container value must keep its underlying IO and lock alive.
- Ngôn ngữ chính
- Perl
- Star
- 67
- Fork
- 8
- Merge trung bình
- 5 giờ 12 phút
- Pull request đã merge (30 ngày)
- 131
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fglock/PerlOnJava
-
area:cpan-port bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fglock/PerlOnJava#2153 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cpan-port area:parser bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fglock/PerlOnJava#2137 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:backend area:cpan-port area:runtime bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fglock/PerlOnJava#2071 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:runtime documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fglock/PerlOnJava#1579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cpan-port bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
fglock/PerlOnJava#2157 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fglock/PerlOnJava
Issue tương tự
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksĐang mởteam-cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 93/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
inverse-inc/packetfence#9728 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(char-create): show the real reason a character is refusedCó thể đã có người làm @baphomello đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày