Close PR - Issue #110450 does not reproduce in current codebase#120871
Close PR - Issue #110450 does not reproduce in current codebase#120871
Conversation
- Add guards to MatchIndex and MatchLength to prevent accessing arrays with negative indices when matchcount is 0 - Add guard to RemoveMatch to prevent matchcount from going negative - Add guard to TidyBalancing to prevent j from going negative - Add test cases for complex balancing group patterns that previously threw exceptions Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, these same helpers are also used by the interpreter, which does not have the same problem. Are you sure the problem is in the helpers? Why doesn't the interpreter hit the issue then? |
You're absolutely right. Both the interpreter and compiled code check I've verified that the patterns from the issue no longer reproduce the exception in the current codebase, suggesting the issue may have been fixed elsewhere or doesn't reproduce consistently. The guards I added are defensive but unnecessary given the existing Should I revert these changes since the helpers already have implicit protection through the |
After investigating @stephentoub's feedback, confirmed that both interpreter and compiled code check IsMatched before calling TransferCapture, which prevents MatchIndex/MatchLength from being called with zero matchcount. The original issue patterns no longer reproduce the exception in current codebase, suggesting it was already fixed or doesn't reproduce consistently. Reverting all changes. Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Closes #110450
Investigation Summary
After investigation, the issue reported in #110450 does not reproduce with the current codebase. All test patterns from the issue work correctly without throwing
ArgumentOutOfRangeException.Root Cause Analysis
The original hypothesis was that
MatchIndexandMatchLengthcould be called with zero matchcount, causing negative array indices. However, investigation revealed that:IsMatchedbefore callingTransferCaptureIsMatchedverifiesmatchcount[cap] > 0before any array accessTesting
Verified all patterns from the issue:
Conclusion
The issue appears to have been already fixed in the codebase or was not consistently reproducible. No changes are needed. This PR can be closed.
Original prompt
Fixes #119444
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.