-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R: Hang possible when building Variables pane #1419
Comments
Since posit-dev/ark#136 we now run all tasks with a timeout of 5 seconds. After this delay, the kernel logs backtraces of the main and calling threads and panics. This timeout is meant for unexpected delays. The panicking behaviour is similar to how we also panic in case of unexpected error/longjump. To avoid these panics, Ark routines need to be defensive by protecting potentially failing code and handling these failures. Similarly we need some mechanism to orderly interrupt operations that can potentially take too much time. I think this could work as follows:
One big caveat with this approach is that we are using a longjump to interrupt the current computation and it would be UB to interrupt a Rust stack this way. In the best case we'll leak memory, in the worst case we'll cause instability in Ark. This means that any computation that might be expected to take too much time (e.g. because it needs to run foreign code) will have to be done in C rather than in Rust. Again we are facing the question of the adequate boundaries between Rust and C code within Ark, with a trade-off between ease of development and safety. |
I can no longer reproduce this. Even though we didn't target this specifically, we have made sevaral changes to the variables pane and how reticulate interacts with Positron. |
Positron Version
2023.09.0-3750
Steps to reproduce the issue:
Create an R file with the following contents (via @t-kalinowski):
Run the first line to set up the environment, then restart R and run the second two.
The R interpreter hangs; now you can't execute code or do anything else with R.
This happens because the Environment pane is waiting on Python when it calls
format
on a vector.We don't know for sure why this hangs in
libpython
, but the suspicion is that it is because reticulate doesn't know that we are running R on a thread other than the main thread (see #1420).What did you expect to happen?
It shouldn't be possible for a badly behaved formatter to freeze the entire interpreter. We could do any/all of:
See also #507; it'd really have been helpful when investigating this to disable the Environment pane.
The text was updated successfully, but these errors were encountered: