Remove dead code and hot-path assertion in _check#4
Closed
Remove dead code and hot-path assertion in _check#4
Conversation
_check() stored the file argument in $_last_call_for for -X _ caching. When the argument was a filehandle reference (not a string path), this prevented the filehandle from being garbage collected, keeping the underlying file descriptor open. This caused "spooky action-at-a-distance" bugs: e.g. a socketpair read hanging because a dup'd write-end filehandle was kept alive by the leaked reference, even after leaving scope. Fix: only cache string filenames in $_last_call_for, not references. Ref: cpan-authors/Test-MockFile#179 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ef-leak fix: prevent filehandle reference leak in stat override
Add CLAUDE.md with project guidance for Claude Code sessions. Exclude CLAUDE.md and local/ directory from Dist::Zilla GatherDir so they don't end up in the CPAN tarball.
Update actions/checkout and CI
- Remove unreachable lines 512-514 in _check_from_stat() after exhaustive if/elsif/else chain (every branch returns or dies) - Remove `die if scalar @others` debug assertion from _check(), which runs on every mocked file check. The XS layer always passes exactly 2 arguments (optype, file), making this check impossible to trigger in production. - Fix stale `$others[0]` reference on line 626 — @Others was always empty since XS passes exactly 2 args, so the fallback was dead code - Add t/check-args-count.t to verify the XS→Perl arg count contract Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
@Koan-Bot squash |
Collaborator
Author
|
Superseded by upstream refactoring: the dead code (unreachable die + return after if/elsif/else chain) was eliminated when _check_from_stat was rewritten as a dispatch table. The stat comment block was extracted into _normalize_stat_result(). Closing. |
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
Remove unreachable dead code and a debug-only assertion from the production hot path.
Why
_check_from_stat()had two unreachable lines (die + return) after an exhaustive if/elsif/else chain where every branch already returns or dies_check()randie if scalar @otherson every mocked file check call, but XS always passes exactly 2 args — this assertion could never trigger and added overhead to the hot path$others[0]reference survived from the old@othersparameter — always undef since XS passes 2 argsHow
_check_from_stat()_check()signature from($optype, $file, @others)to($optype, $file)$out // $others[0]with$outt/check-args-count.tto verify the XS→Perl 2-argument contractTesting
Full test suite passes: 51 files, 1073 tests, 0 failures.
🤖 Generated with Claude Code