-
Notifications
You must be signed in to change notification settings - Fork 50
Reproducible segmentation fault (with tidyr and openxlsx), bisect included #244
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
Comments
It is also generally worth noting that I can't seem to reproduce this with an old version of tidyr that used Rcpp, but soon after the switch to cpp11 this starts happening. It has proved to be difficult to isolate though |
I so far have been unable to reproduce this either on macOS or in a Ubuntu Docker container. The behavior looks like either stack corruption or a protection failure, but it is going to be difficult to track down unless I can reproduce it myself. |
I had hoped that an example that fails on Windows and Linux is universal, but it seems not. But I can provider some further information. Windows is Windows 10 21H2, R 4.1.1 Here's a session info from WSL (before the loop):
What else could be helpful for me to provide? |
I've managed to reproduce this without tidyr
Open up an R Console and run this and for me it segfaults most of the time (running this in RStudio won't immediately crash it, but it often makes further processing hang and eventually segfault somewhere) invisible(gctorture2(50))
cpp11::cpp_function(
'
cpp11::list fn_cpp() {
cpp11::writable::list out(4);
return out;
}
'
)
fun2 <- function() {
openxlsx::write.xlsx(as.data.frame(1), tempfile())
}
y <- fn_cpp()
fun2()
while (TRUE) {
print(fn_cpp())
} |
@DavisVaughan great job. I had to |
It seems relying on non-local static objects can cause memory issues, that are resolved by moving to use a local static objects instead. Fixes #244
Ok, I have finally be able to reproduce this, I think the problem was I was using R 4.1.0 rather than 4.1.1+, and I didn't encounter the crash with that version. #245 resolves this for me, @bersbersbers could you try that with your more full examples and verify it fixes the problem there as well? |
I ran my example above with |
Test log:
This looks pretty consistent in that installing #245 and reinstalling |
Tests using my original code took a bit longer, so here is the condensed log:
Thanks again! |
It seems relying on non-local static objects can cause memory issues, that are resolved by moving to use a local static objects instead. Fixes #244
Open R and copy-and-paste this:
gives
I can repro the problem on five OSes: 1 x OpenSUSE Leap 15.2, 2 x Windows 10, and 2 x Ubuntu 20.04 in Windows 10 WSL.
This issue has a long history with me (tidyverse/tidyr#1163, ycphs/openxlsx#267, tidyverse/ggplot2#4635, rstudio/rmarkdown#2229, thomasp85/patchwork#278).
After bisecting CRAN releases of
tidyr
, I finally bisectedcpp11
from GitHub and found 087861f as the first bad commit. More details below.I am still not convinced that cpp11 is the culprit, but developers of
openxlsx
andtidyr
, while being able to reproduce the issue, don't find the source in their code base, either. So maybe people here have an idea.The text was updated successfully, but these errors were encountered: