Fix deep recursion stack overflow on Windows#72
Merged
atoomic merged 1 commit intogaru:masterfrom Feb 17, 2026
Merged
Conversation
Contributor
Author
Recreated: Fix deep recursion stack overflow on WindowsThe original branch Branch Actions
Automated by Kōan |
Koan-Bot
added a commit
to atoomic/Clone
that referenced
this pull request
Feb 17, 2026
75f4b00 to
5de1aa8
Compare
5de1aa8 to
225430b
Compare
2 tasks
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.
Summary
Fixes
t/10-deep_recursion.tcrash on Windows (CPAN Testers: exit 255, 3/5 subtests failed).Root cause: Deeply nested arrayrefs like
[[[...]]]consume ~3 C stack frames per nesting level during recursive cloning. Windows has a 1MB default thread stack (vs 8MB on Linux/macOS), causing stack overflow well before theMAX_DEPTHsafety limit was reached.Three interrelated bugs fixed:
MAX_DEPTH: 4000 on Windows (safe for ~2000 nesting levels), 32000 elsewhereMAX_DEPTHRV→AV routing: The depth check only handledSVt_PVAVbut the[[[...]]]pattern alternates RV/AV — the limit was always first hit on an RV, falling through toSvREFCNT_inc(ref)which produced a shared (not deep-copied) inner structureav_clone_iterativerewrite: Fixed two bugs — returned chain tail instead of root (lost nesting levels), and used stale seen-hash keyTest rewrite: Removed
Devel::PeekandDevel::Sizedependencies (unnecessary risk), tests 35000-level nesting built iteratively, added clone-independence mutation test.CPAN Testers report: https://magpie.cpantesters.org/results/5483df40-720f-1014-847a-9de21b4fca93
Test plan
🤖 Generated with Claude Code