admin管理员组文章数量:1322850
This question builds on a previous solution, where a method was requested to restrict R functions for use in an exam: Restrict R functions for an exam
The solution marked as accepted works very well. However, I have a follow-up question.
Currently, on Windows, pressing the TAB key triggers an error stating "utils:::.win32consoleCompletion is Forbidden," which causes the R console to close unexpectedly. While I am fine with disabling autocompletion, it is crucial that the R console does not close abruptly, as this would result in the loss of variables. For example, if a student prepares some variables and then accidentally presses TAB, they would lose all their work.
The .Rprofile of the linked answer is used. R.exe is started through a batch-file with the .Rprofile on the command line interface of Windows.
This question builds on a previous solution, where a method was requested to restrict R functions for use in an exam: Restrict R functions for an exam
The solution marked as accepted works very well. However, I have a follow-up question.
Currently, on Windows, pressing the TAB key triggers an error stating "utils:::.win32consoleCompletion is Forbidden," which causes the R console to close unexpectedly. While I am fine with disabling autocompletion, it is crucial that the R console does not close abruptly, as this would result in the loss of variables. For example, if a student prepares some variables and then accidentally presses TAB, they would lose all their work.
The .Rprofile of the linked answer is used. R.exe is started through a batch-file with the .Rprofile on the command line interface of Windows.
Share Improve this question edited Jan 21 at 12:52 Johannes Titz asked Jan 14 at 14:57 Johannes TitzJohannes Titz 1,0018 silver badges13 bronze badges 8 | Show 3 more comments1 Answer
Reset to default 2This is caused by a bug in earlier versions of R on Windows. Pressing TAB triggered a problem in utils:::.win32consoleCompletion()
, which caused R to crash.
Essentially, the bug occurred because R wasn't able to gracefully catch certain errors during autocompletion. .win32consoleCompletion()
was evaluated in a separate thread, which used incorrect stack start detection for overflow checks. R's error-handling mechanism wasn't able to reliably guard against long jumps caused by errors during autocompletion. This combination sometimes led to a stack overflow or invalid memory access, causing R to exit unexpectedly.
This has been fixed from R 4.2.2 and should be resolved simply by updating R. The fix ensures that autocompletion requests are routed through the main thread, using a dummy window for synchronisation and robust error handling. You can read the full details in an R Project blog post.
本文标签: Problem with Autocompletion in Restricted R Environments for Exams under WindowsStack Overflow
版权声明:本文标题:Problem with Autocompletion in Restricted R Environments for Exams under Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742112572a2421319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
.Rprofile
you're using - especially if you made the suggested changes to tighten access to thecompiler
package. Regarding how to disable autocomplete, you've mentioned the Safe Exam Browser but how are you accessing R in the browser? With an IDE? Also just to note I'm still sceptical of approach. While the accepted answer made R far more secure than I thought possible, a quick web search finds multiple ways to bypass Safe Exam Browser itself e.g. through opening it in a virtual machine and browsing the web on the main device. – SamR Commented Jan 14 at 15:41.win32consoleCompletion
, until the errors go away. – Konrad Rudolph Commented Jan 15 at 15:15win32consoleCompletion -> pleteToken -> specialCompletions -> specialOpCompletionsHelper -> tryToEval -> eval
. @JohannesTitz Which version of R are you using? A forbidden function being called shouldn't cause the R console to crash. There was a bug where any errors in this function would crash R that was reportedly fixed in R 4.2.3. – SamR Commented Jan 15 at 15:45rc.settings(ops = FALSE)
in your R profile. But I believe that that this instance ofeval()
is also safe: even if the user could inject arbitrary expressions here (and I don’t think they can!), the evaluation takes place in the global environment and therefore cannot run anything that the user couldn’t run anyway. – Konrad Rudolph Commented Jan 15 at 16:06