Skip to content

Reproducible segmentation fault (with tidyr and openxlsx), bisect included #244

Closed
@bersbersbers

Description

@bersbersbers

Open R and copy-and-paste this:

x <- data.frame()
invisible(gctorture2(50))

fun1 <- function() {
    as.data.frame(tidyr:::simplifyPieces(
        list(c("A", "A"), c("A", "B"), c("B", "A"), c("B", "B")), 2, FALSE
    )$strings)
}

fun2 <- function() {
    openxlsx::write.xlsx(as.data.frame(1), tempfile())
}

y <- fun1() # try(fun1) does not repro!
fun2()
while (TRUE) {
    print(fun1())
}

gives

 *** caught segfault ***
address 0x55bb00000004, cause 'memory not mapped'

Traceback:
 1: print.data.frame(fun1())
 2: print(fun1())

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: `

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 bisected cpp11 from GitHub and found 087861f as the first bad commit. More details below.

Using R -e 'devtools::install_version("cpp11", "0.4.0"); install.packages("tidyr")' && R # repro!
Using R -e 'devtools::install_version("cpp11", "0.3.1"); install.packages("tidyr")' && R # no repro!

Using R -e 'devtools::install(); install.packages("tidyr")' && R
29ce41de04a6cc884f0217009c9e00b8c611d0c4 (master) bad
5a26bdb8e83d96e78c49bdb14024409309825a62 (v0.3.1) bad (must have been a mistake)
7d9195f47b9c653f05ff888eac4a6ef6d3389439 (v0.3.0) good
73e1acb15bcaac6b9c2c72804b1c0e4fdaeab9c0 good
5a26bdb8e83d96e78c49bdb14024409309825a62 good
5a26bdb8e83d96e78c49bdb14024409309825a62 (v0.3.1) good
1c84e03239dd759c8e8f52d185d9acf3c1251041 bad
9df63865765284ded32ab49bb44deb3c48d385f5 good
ac7374e81bb9e8fe35b21424c53e21b91b00c9e4 good
cde1872c8000b79e008420f5923dbfe2eb51e953 bad
087861f9ee2383d717255ecb0487e4b297808c49 bad
b9ec7eb4448b3eeea47e65df917f69034fda926c good
087861f9ee2383d717255ecb0487e4b297808c49 first bad!

I am still not convinced that cpp11 is the culprit, but developers of openxlsx and tidyr, while being able to reproduce the issue, don't find the source in their code base, either. So maybe people here have an idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions