fix: track IO::File handles in array to support concurrent opens - #426
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: track IO::File handles in array to support concurrent opens#426toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
_io_file_mock_open stored each IO::File handle in the scalar {'fh'} slot,
which is also used by opendir for directory handles. Opening a second
IO::File handle to the same mock overwrote the first, making it invisible
to _fh_to_file — breaking stat(), truncate(), and any filehandle-to-path
lookup on the first handle.
Switch to the {'fhs'} array pattern already used by __open, which
supports multiple concurrent handles per mock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix
_io_file_mock_opento use the{'fhs'}array instead of the scalar{'fh'}slot for tracking open IO::File handles.Why
Opening a second
IO::Filehandle to the same mocked file overwrote the first handle's tracking reference, making it invisible to_fh_to_file. This brokestat(),truncate(), and any filehandle-to-path lookup on the first handle — returning EBADF instead of the file's metadata.The
{'fh'}scalar slot is also used by__opendirfor directory handles. While files and directories don't collide in practice, using the same slot for two different purposes is a latent conflict.How
Changed
_io_file_mock_openfrom:to the
{'fhs'}array pattern already used by__open:Testing
t/io_file_compat.tcovering multiple concurrentIO::Filehandles and handle lookup surviving peer closefh-ref-leak.tfailure)Quality Report
Changes: 2 files changed, 44 insertions(+), 3 deletions(-)
Code scan: clean
Tests: failed (4 Failed, 94 test)
Branch hygiene: clean
Generated by Kōan