Repository navigation
fix: debugSource error when keep.source is FALSE #12375 - #18686
AzazelSensei wants to merge 16 commits into
Conversation
parse() leaves srcref NULL in that case, and structure(NULL, *) warned from makeSourceEquivFunction.
|
Thanks for the PR, we'll take a look at it as soon as we can. If you haven't already, please fill out and submit the contributor agreement: https://github.com/rstudio/rstudio/blob/main/CONTRIBUTING.md#contributing-code. |
Return early on a length-0 parse so 1:length(content) does not run, and treat a missing srcref the same as an empty one.
|
Took the empty-file early return after parse, and switched the srcref guard to length(refs) == 0. Left out the message() so the #12375 path stays quiet. Agreed on the srcfile skip — that attr is NULL when keep.source is FALSE. Updated NEWS and the title from warns to errors. |
|
I don't think we've received your contributor agreement (but please correct me if I'm wrong!). |
|
Oh, actually, I should be able to make the fixes directly on your fork, if the settings allow it. I'll check that. Update: done! I've addressed the feedback, fixed merge issues, etc. So once I've got confirmation of your CLA submission we should be good to go. |
kevinushey
left a comment
There was a problem hiding this comment.
No actionable findings at 056bd25471a17a352cae11447c6ed44c2165c742.
The early returns preserve execution when source references are unavailable and safely handle empty or comment-only files. I checked the surrounding debugger execution and breakpoint handling paths.
Validation: the debugger test suite passed all 36 assertions with no warnings or skips, using this PR's R code loaded into the existing session binary. Additional execution checks with warnings treated as errors, including stored breakpoints, also passed.
CI builds were still running at the time of review.
|
Still waiting on the contributor agreement, and code freeze is about to happen so moving this to next milestone. |
|
@AzazelSensei wanted to reach out once more about the CLA. |
|
Thanks again for this PR, and for pinpointing the empty-file case on top of the reported one. Unfortunately we can't merge contributions without a signed contributor agreement (see CONTRIBUTING.md), and we weren't able to get one here, so we've re-implemented the fix ourselves in #19284, which credits your work. Closing this one in favour of that. |
Intent
debugSource()warns whenoptions(keep.source = FALSE)becauseparse()leavessrcrefNULL andmakeSourceEquivFunction()still callsstructure()on it. #12375Approach
.rs.makeSourceEquivFunction()returns early in two places:parse(), when the file has no expressions (empty or comment-only). Before,1:length(content)iterated withi = 1and failed withsubscript out of bounds.fun, whenlength(refs) == 0. Withkeep.source = FALSE,parse()leavessrcrefNULL, and the old code failed withattempt to set an attribute on NULL. Only the source-reference metadata is skipped, so the file still runs; breakpoints have no effect without srcrefs.Automated Tests
Two tests in
src/cpp/tests/testthat/test-debugger.Rcall.rs.makeSourceEquivFunction()on:keep.source = FALSE, checking that it still runs and assigns into the target environmentkeep.sourceboth on and offRun with
./build/src/cpp/rstudio-tests --scope r --filter debugger.QA Notes
Not yet checked by hand in RStudio. The new tests fail against
main'sSessionBreakpoints.Rand pass with this change. To check manually, run the reporter's snippet; it should printHello, world!with no error:Also run
debugSource()on an empty file and on a file containing only a comment, withkeep.sourceon and off; each should finish without error.Documentation
NEWS.md under Fixed.
Checklist
NEWS.md