Fix set_call_limit to track recursion depth and prevent stack overflow#1140
Fix set_call_limit to track recursion depth and prevent stack overflow#1140
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
|
@copilot can just set_call_limit be fixed (to incorporate set_depth_limit) instead of introducing a new function? |
I considered merging them, but keeping separate functions is better because:
The two limits serve complementary purposes:
If you'd prefer a unified API, I could explore these alternatives:
Let me know if you'd like me to refactor to a different approach. |
|
@copilot the primary function of set_call_limit should be the same as of set_depth_limit, i.e. its implementation can be replaced by it |
As requested by @tomtau, removed separate set_depth_limit function and fixed set_call_limit to track actual recursion depth (increment on entry, decrement on exit) instead of just total calls. This makes set_call_limit properly prevent stack overflow from deep recursion as originally intended. Changes: - Removed DEPTH_LIMIT static and set_depth_limit function - Modified CallLimitTracker to only track recursion depth (not total calls) - Simplified implementation by removing separate call/depth tracking - Updated all tests to use set_call_limit instead of set_depth_limit - Updated documentation to reflect that set_call_limit now tracks depth Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Fixed in commit 2b956db.
Key changes:
|
|
@copilot |
Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
|
@copilot |
- Fixed doc comment indentation issues in lib.rs and parser_state.rs - Fixed lifetime syntax in test files and examples (use Pairs<'_, Rule>) - Fixed unused variable warning in depth_limit test - Updated benchmark to use repeat_n instead of repeat().take() Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
Fix set_call_limit to track recursion depth and prevent stack overflow
Fixed
set_call_limitto track recursion depth properly (increment/decrement) instead of adding a separateset_depth_limitfunction, as requested by @tomtau.Changes
Fixed
set_call_limitimplementation:DEPTH_LIMITandset_depth_limitfunctionCallLimitTrackerto only track depth (removed call count tracking)Rationale:
The original
set_call_limithad a method calledincrement_depthbut never decremented, making it track total calls instead of recursion depth. This fix makes it work as originally intended - preventing stack overflow by limiting recursion depth.Testing:
set_call_limit)API
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.