Repository navigation
Reproducible Segfault When Loading/Unloading data.table #990
Description
Activity
Thanks for the report. Reproducible. Please make sure you've read the contribution guidelines.
Arun, I did read the contribution guidelines. What did I miss?
Remove the
>and comment the output, so that it's easy to copy/paste. I edited yours.It seems like the bug above was not fixed in 1.9.5:
The code below creates a fatal crash in my fresh R session (after running it multiple times):library(data.table) DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9) detach("package:data.table", unload=TRUE)Interestingly, this seems to be ok:
library(data.table) #DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9) detach("package:data.table", unload=TRUE)Here is my sessionInfo():
R version 3.2.1 (2015-06-18) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.9.5 (Mavericks) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] data.table_1.9.5 devtools_1.8.0 loaded via a namespace (and not attached): [1] httr_1.0.0 R6_2.1.0 magrittr_1.5 rversions_1.0.1 tools_3.2.1 curl_0.9.1 Rcpp_0.12.0 [8] memoise_0.2.1 xml2_0.1.1 stringi_0.5-5 knitr_1.10.5 git2r_0.10.1 stringr_1.0.0 digest_0.6.8 [15] chron_2.3-47Same things happen on 1.9.4
Still reproducible in 1.9.6, though we need to add the additional
librarycall at the end.library(data.table) dt.1 <- data.table(a=1:10, b=1:10) detach("package:data.table", character.only=TRUE, unload=TRUE) library(data.table) # *** caught segfault *** # address 0x110eb2300, cause 'memory not mapped' # # Possible actions: # 1: abort (with core dump, if enabled) # 2: normal R exit # 3: exit R without saving workspace # 4: exit R saving workspaceCannot reproduce it anymore, must have been fixed in the last 5 years. Checked on Linux. I would appriciate if someone on Windows and Mac could confirm as well if it is fixed.
library(data.table) #data.table 1.12.9 IN DEVELOPMENT built 2020-04-03 10:50:14 UTC; jan using 1 threads (see ?getDTthreads). Latest news: r-datatable.com dt.1 <- data.table(a=1:10, b=1:10) detach("package:data.table", character.only=TRUE, unload=TRUE) library(data.table) #data.table 1.12.9 IN DEVELOPMENT built 2020-04-03 10:50:14 UTC; jan using 1 threads (see ?getDTthreads). Latest news: r-datatable.com
Still happening on OS X:
R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(data.table) data.table 1.12.2 using 2 threads (see ?getDTthreads). Latest news: r-datatable.com dt.1 <- data.table(a=1:10, b=1:10) detach("package:data.table", character.only=TRUE, unload=TRUE) library(data.table) *** caught segfault *** address 0x11147dfe0, cause 'memory not mapped' 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:Maybe R version-specific? not happening for me on OSx
> sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib locale: [1] C/UTF-8/C/C/C/C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.6.0 > library(data.table) data.table 1.12.9 IN DEVELOPMENT built 2020-02-20 09:16:40 UTC; travis using 4 threads (see ?getDTthreads). Latest news: r-datatable.com ********** This development version of data.table was built more than 4 weeks ago. Please update: data.table::update.dev.pkg() ********** > data.table 1.12.2 using 2 threads (see ?getDTthreads). Latest news: r-datatable.com エラー: 想定外の数値定数です in "data.table 1.12" > dt.1 <- data.table(a=1:10, b=1:10) > detach("package:data.table", character.only=TRUE, unload=TRUE) > library(data.table) data.table 1.12.9 IN DEVELOPMENT built 2020-02-20 09:16:40 UTC; travis using 4 threads (see ?getDTthreads). Latest news: r-datatable.com ********** This development version of data.table was built more than 4 weeks ago. Please update: data.table::update.dev.pkg() **********Reacted by Jan GoreckiI tried again with
1.12.8and this appears to have gone away.Reacted by Jan Gorecki and Michael ChiricoNothing particularly stands out to me as a fix for this issue, but anyway, this commit came up from
git bisectas the first fixed commitThe issue still exists in current
master:library(data.table) x <- as.data.table(mtcars) detach('package:data.table', unload = TRUE) rm(x) gc(full = TRUE)Thread 1 "R" received signal SIGSEGV, Segmentation fault. 0x00007fff71c91670 in ?? () (gdb) bt #0 0x00007fff71c91670 in ?? () #1 0x00007ffff7b92d29 in R_RunWeakRefFinalizer (w=<optimized out>) at ../../../src/main/memory.c:1522 #2 0x00007ffff7b92faa in RunFinalizers () at ../../../src/main/memory.c:1589 #3 0x00007ffff7b93095 in R_RunPendingFinalizers () at ../../../src/main/memory.c:1625 #4 0x00007ffff7b9679e in R_gc () at ../../../src/main/memory.c:3167The crash is due to the package DLL containing the finalizer having been unloaded from the address space despite the object still exists. On R < 3.4, the finalizer is an excellent hack, the only way to make sure that R counts memory correctly; otherwise, the over-allocated part of the list of pointers is not accounted for when the memory is released. On R ≥ 3.4,
SET_GROWABLE_BITcould be used instead... if it was an API entry point.
In the R console:
This is the session info before running the above code:
This also happens in 1.9.4. In RStudio, segfault doesn't happen right away, but running code multiple times eventually causes it to happen.
Also reproduced with 1.9.4 in R3.1.2 on Win7.64.