fix: reset Perl-level mock state in ithreads CLONE#102
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: reset Perl-level mock state in ithreads CLONE#102Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
The XS CLONE handler correctly starts child threads with all ops unmocked (is_mocked=0), but the Perl-level $_current_mocks hash was not cleared. This caused mock_file_check() in child threads to croak "already mocked" for ops mocked in the parent. Add _clone_init() called from XS CLONE to reset $_current_mocks and $_last_call_for. Add ithreads-clone.t (skips on non-threaded perls). Co-Authored-By: Claude <noreply@anthropic.com>
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
Reset
$_current_mocksand$_last_call_forwhen a child thread is created under ithreads.Why
The XS
CLONEhandler correctly starts each child interpreter with all ops unmocked (is_mocked = 0), but the Perl-level$_current_mockshash was deep-copied with stale entries from the parent. This causedmock_file_check()in child threads to croak "-X is already mocked" for any op that was mocked in the parent thread.How
_clone_init()inFileCheck.pmthat resets both$_current_mocksand$_last_call_forCLONEviacall_pv()after theOverloadFTOpsstruct is allocatedTesting
t/ithreads-clone.t— verifies child threads can mock independently, parent state doesn't leak, parent mock survives child exit. Skips on non-threaded perls.🤖 Generated with Claude Code
Quality Report
Changes: 3 files changed, 84 insertions(+)
Code scan: clean
Tests: passed (0 Tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline