RStudio Server crashes with SEGV when executing python chunk

I'm running into a problem for which I haven't been able to figure out either a direct cause or a workaround, and am looking for some insight or help.

When executing any python chunks "live" in an Rmd notebook, the rsession will terminate with a SEGV; the UI will put up a 'failed transmission' message, and then inform that the session abnormally terminated.

The notebook can be as simple as

```{r setup}

The problem is happening on multiple versions of R and RStudio Server, but the details below are for 1.3.878, with R 3.6.2 (also seen with 3.6.1 prior to updating today) on CentOS 8 (1905).
I do not have the same issue when running on Mac desktop (also 1.3.878, using R 3.6.0), so the issue seems to me to be limited to either linux in general or studio server in particular.

I don't think there is anything fundamental about the python versions, or the R packages, because I am able to knit to e.g. an html document, and everything works as expected. This seems to happen only when working with notebooks in a live session.

In case it gives anyone a clue, the short summary from logs for my latest experiment is:

Mar 04 11:03:15 nhx2-centos8-1 rsession-janitor[26017]: ERROR session hadabend; LOGGED FROM: rstudio::core::Error {anonymous}::rInit(const rstudio::r::session::RInitInfo&) src/cpp/session/SessionMain.cpp:653
Mar 04 11:03:48 nhx2-centos8-1 rsession-janitor[26035]: WARNING ASSERTION FAILED: pthread_mutex_lock(&m_) == 0; LOGGED FROM: void rstudio_boost::signals2::mutex::lock() /opt/rstudio-tools/boost/boost_1_69_0/include/boost/signals2/detail/lwm_pthreads.hpp:60
Mar 04 11:03:48 nhx2-centos8-1 rsession-janitor[26035]: WARNING ASSERTION FAILED: pthread_mutex_unlock(&m_) == 0; LOGGED FROM: void rstudio_boost::signals2::mutex::unlock() /opt/rstudio-tools/boost/boost_1_69_0/include/boost/signals2/detail/lwm_pthreads.hpp:70

and var/log/messages reports

[4329560.746672] traps: rsession[24780] general protection ip:557dd89e2c55 sp:7ff587ffe490 error:0 in rsession[557dd8110000+1035000]
[4330916.598307] rsession[26047]: segfault at 21 ip 0000000000000021 sp 00007fd66e74df98 error 14 in rsession[562d50b4e000+1035000]
[4330916.598315] Code: Bad RIP value.

I managed to capture a complete coredump, if that would be useful.

FWIW, the other instance is 1.2.5033 with MRO 3.5.1. The problem didn't exist here when python chunks were last used (almost a year ago), so the problem may have appeared with the switch to 1.2.5, and there have been several package and python updates in the interim, to the point where reverting back to a known good state isn't really feasible.

Thanks for any help or clues!


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

I managed to find the cause of the problem described in RStudio Server crashes with SEGV when executing python chunk

The crash, which is actually in rsession, not rstudio-server (I should have been more explicit before) seems to be related to Qt being unable to attach to an X display.

The workaround that I found is to add


to the global Renviron. I'm not sure if this is the best, or only, solution, but it resolves the problem in our case, since we don't have need of using X displays directly.

If the maintainers decide that this is buggable, I do still have a full core dump available. It would be nice if it were handled a bit better inside of rsession, such that it at least was able to handle the error condition without crashing.