[util][rpdb] Fix IndexError in legacy post-mortem debugging#61479
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses a potential IndexError in the legacy post-mortem debugging functionality. The issue arises when _connect_ray_pdb attempts to access a specific frame index that may not exist if the call stack is not deep enough. The change introduces a check for the number of available frames and falls back to the last available frame if the stack depth is insufficient. The fix is correct and robustly handles the described edge case. I have no further comments.
When using RAY_DEBUG=legacy with RAY_DEBUG_POST_MORTEM=1, the _post_mortem() function calls _connect_ray_pdb() which tries to access inspect.getouterframes(...)[2]. However, the frame depth may not always be sufficient, causing IndexError. Fix: Add a fallback to use the last available frame when there aren't enough frames in the call stack. Fixes ray-project#61470 Signed-off-by: Hiren <hiren.thakore58@gmail.com>
eceeeeb to
c4a3d61
Compare
|
hi @justinvyu , can you help take a look at this one line fix? Thanks |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
pseudo-rnd-thoughts
left a comment
There was a problem hiding this comment.
Thanks for the PR, LGTM
…ect#61479) ## Summary Fixes ray-project#61470 When using `RAY_DEBUG=legacy` with `RAY_DEBUG_POST_MORTEM=1`, the `_post_mortem()` function calls `_connect_ray_pdb()` which tries to access `inspect.getouterframes(...)[2]`. However, the frame depth may not always be sufficient, causing `IndexError: list index out of range`. ## Changes - Added a fallback in `_connect_ray_pdb()` to use the last available frame when there aren't enough frames in the call stack - The fix: `frames[2] if len(frames) > 2 else frames[-1]` ## Testing The fix ensures that: 1. Normal set_trace() paths continue to work (frame depth is predictable) 2. Post-mortem debugging paths no longer crash with IndexError ## Checklist - [x] I've signed off every commit (git commit -s) (N/A: single commit) - [x] I've updated tests (N/A: defensive fix for edge case) - [x] I've linked this PR to the relevant issue ## Related Issues Fixes ray-project#61470 Signed-off-by: Hiren <hiren.thakore58@gmail.com> Co-authored-by: Mark Towers <mark.m.towers@gmail.com> Signed-off-by: anindyam1969 <amukherjee@kinetica.com>
Summary
Fixes #61470
When using
RAY_DEBUG=legacywithRAY_DEBUG_POST_MORTEM=1, the_post_mortem()function calls_connect_ray_pdb()which tries to accessinspect.getouterframes(...)[2]. However, the frame depth may not always be sufficient, causingIndexError: list index out of range.Changes
_connect_ray_pdb()to use the last available frame when there aren't enough frames in the call stackframes[2] if len(frames) > 2 else frames[-1]Testing
The fix ensures that:
Checklist
Related Issues
Fixes #61470