-
Notifications
You must be signed in to change notification settings - Fork 41
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
Importing fst into another package causes the other package to crash R #109
Comments
Hi @eipi10, thanks for reporting your issue! That's a curious problem indeed. Because you're using OSX Sierra, I'm thinking that the It would be great if you could try building the empty RStudio project with an import of Package I'll try to reproduce your empty project crash myself although I don't have access to an OSX Sierra box currently (if that's the cause). Thanks for reporting (and testing)! |
Hi @eipi10, I've build an empty RStudio package that only imports Here is the zipped package directory (hope you can unpack that cleanly). I followed the following steps to create, build and check it:
The check runs without errors on my (Win10 and Ubuntu) systems. Then I can run: fsttester::openmp_info()
#> OpenMP enabled : TRUE
#> Number of threads: 8 Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.2 (2017-09-28)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> tz Europe/Berlin
#> date 2017-12-02
#> Packages -----------------------------------------------------------------
#> package * version date source
#> backports 1.1.1 2017-09-25 CRAN (R 3.4.1)
#> base * 3.4.2 2017-09-28 local
#> compiler 3.4.2 2017-09-28 local
#> datasets * 3.4.2 2017-09-28 local
#> devtools 1.13.4 2017-11-09 CRAN (R 3.4.2)
#> digest 0.6.12 2017-01-27 CRAN (R 3.4.2)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)
#> fst 0.7.3 2017-12-02 local
#> fsttester 0.1.0 2017-12-02 local
#> graphics * 3.4.2 2017-09-28 local
#> grDevices * 3.4.2 2017-09-28 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.1)
#> knitr 1.17 2017-08-10 CRAN (R 3.4.1)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.2)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.2)
#> methods * 3.4.2 2017-09-28 local
#> parallel 3.4.2 2017-09-28 local
#> Rcpp 0.12.14 2017-11-23 CRAN (R 3.4.2)
#> rmarkdown 1.8 2017-11-17 CRAN (R 3.4.2)
#> rprojroot 1.2 2017-01-16 CRAN (R 3.4.2)
#> stats * 3.4.2 2017-09-28 local
#> stringi 1.1.6 2017-11-17 CRAN (R 3.4.2)
#> stringr 1.2.0 2017-02-18 CRAN (R 3.4.2)
#> tools 3.4.2 2017-09-28 local
#> utils * 3.4.2 2017-09-28 local
#> withr 2.1.0 2017-11-01 CRAN (R 3.4.2)
#> yaml 2.1.14 2016-11-12 CRAN (R 3.4.1) I'm curious to see if the greetings and thanks for testing |
Hi Marcus, My copy of So, as you surmised, it looks like it's related to OSX systems with OpenMP. Any ideas on how to resolve this? It looks like I can build packages that don't import Thanks for your help. Joel |
Hi @eipi10, thanks for testing! Indeed the fact that Your issues seems related to this issue in the You could try to comment-out the code in that method (in a fresh (but not solved it yet :-)) |
I installed OpenMP (can't remember if that was part of a clang installation) a few months ago in order to take advantage of multiple cores with I've been using |
FWIW I'm experiencing what I think is the same issue. Building my fstArray package () using I am on macOS 10.12.6, running a recent-ish build of R-devel with OpenMP supported via clang 4.0 (installed following instructions at https://cran.r-project.org/bin/macosx/tools/), and I installed fst using Unfortunately, in my case, resorting to I'm very happy to help out with further testing but won't have time until later this week. Thanks for your great work on fst, Marcus! Session info#> sessionInfo()
R Under development (unstable) (2017-10-30 r73642)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] colorout_1.1-3 repete_0.0.0.9010 devtools_1.13.4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 whisker_0.3-2 knitr_1.17 XVector_0.19.1
[5] magrittr_1.5 GenomicRanges_1.31.1 BiocGenerics_0.25.0 zlibbioc_1.25.0
[9] IRanges_2.13.4 munsell_0.4.3 colorspace_1.3-2 stringr_1.2.0
[13] GenomeInfoDb_1.15.1 plyr_1.8.4 tools_3.5.0 parallel_3.5.0
[17] clipr_0.4.0 withr_2.1.0 htmltools_0.3.6 fortunes_1.5-4
[21] rprojroot_1.2 yaml_2.1.15 digest_0.6.12 GenomeInfoDbData_0.99.2
[25] callr_1.0.0 pryr_0.1.3 S4Vectors_0.17.12 bitops_1.0-6
[29] codetools_0.2-15 RCurl_1.95-4.8 evaluate_0.10.1 memoise_1.1.0
[33] rmarkdown_1.8 reprex_0.1.1 stringi_1.1.6 compiler_3.5.0
[37] backports_1.1.1 scales_0.5.0 stats4_3.5.0
#> devtools::session_info()
Session info ------------------------------------------------------------------------
setting value
version R Under development (unstable) (2017-10-30 r73642)
system x86_64, darwin15.6.0
ui RStudio (1.1.379)
language (EN)
collate en_AU.UTF-8
tz America/New_York
date 2017-12-11
Packages ----------------------------------------------------------------------------
package * version date source
base * 3.5.0 2017-10-31 local
BiocGenerics * 0.25.0 2017-10-31 Bioconductor
bitops 1.0-6 2013-08-17 CRAN (R 3.5.0)
codetools 0.2-15 2016-10-05 CRAN (R 3.5.0)
colorout * 1.1-3 2017-10-31 Github (jalvesaq/colorout@e2a175c)
colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
commonmark 1.4 2017-09-01 CRAN (R 3.5.0)
compiler 3.5.0 2017-10-31 local
datasets * 3.5.0 2017-10-31 local
DelayedArray * 0.5.7 2017-12-06 Bioconductor
devtools * 1.13.4 2017-11-09 CRAN (R 3.5.0)
digest 0.6.12 2017-01-27 CRAN (R 3.5.0)
fortunes 1.5-4 2016-12-29 CRAN (R 3.5.0)
fst 0.7.3 2017-12-11 Github (fstpackage/fst@e060e62)
fstArray * 0.0.0.9005 <NA> Bioconductor
GenomeInfoDb 1.15.1 2017-11-12 Bioconductor
GenomeInfoDbData 0.99.2 2017-11-13 Bioconductor
GenomicRanges 1.31.1 2017-11-17 Github (Bioconductor/GenomicRanges@d65bed4)
graphics * 3.5.0 2017-10-31 local
grDevices * 3.5.0 2017-10-31 local
IRanges * 2.13.4 2017-11-22 Bioconductor
magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
matrixStats * 0.52.2 2017-04-14 CRAN (R 3.5.0)
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods * 3.5.0 2017-10-31 local
munsell 0.4.3 2016-02-13 CRAN (R 3.5.0)
parallel * 3.5.0 2017-10-31 local
plyr 1.8.4 2016-06-08 CRAN (R 3.5.0)
pryr 0.1.3 2017-10-30 CRAN (R 3.5.0)
R6 2.2.2 2017-06-17 CRAN (R 3.5.0)
Rcpp 0.12.14 2017-11-23 CRAN (R 3.5.0)
RCurl 1.95-4.8 2016-03-01 CRAN (R 3.5.0)
repete * 0.0.0.9010 2017-11-24 Github (PeteHaitch/repete@db2caea)
roxygen2 6.0.1 2017-02-06 CRAN (R 3.5.0)
S4Vectors * 0.17.12 2017-12-02 cran (@0.17.12)
scales 0.5.0 2017-08-24 CRAN (R 3.5.0)
stats * 3.5.0 2017-10-31 local
stats4 * 3.5.0 2017-10-31 local
stringi 1.1.6 2017-11-17 CRAN (R 3.5.0)
stringr 1.2.0 2017-02-18 CRAN (R 3.5.0)
tools 3.5.0 2017-10-31 local
utils * 3.5.0 2017-10-31 local
withr 2.1.0 2017-11-01 CRAN (R 3.5.0)
xml2 1.1.1 2017-01-24 CRAN (R 3.5.0)
XVector 0.19.1 2017-11-17 Bioconductor
yaml 2.1.15 2017-12-01 CRAN (R 3.5.0)
zlibbioc 1.25.0 2017-10-31 Bioconductor |
Hi @PeteHaitch, thanks for reporting and your I guess the ideas we shared in issue #19 are still very relevant to optimize the speed in your package? If the speed is now comparable to It would take a series of Anyway, these OpenMP problems on macOS are quite troublesome. So your master branch has no problems because the current CRAN version has no OpenMP dependencies. It guess we could still test a couple of things:
Do you have the same problems if you attach the greetings |
Hi @MarcusKlik, Yes, #19 would be brilliant! I decided in the meanwhile to experiment with supporting matrix-like data that are backed via an fst data frame. The good news is that I'm finding it very promising: a common data access pattern I face as a package developer and user is to access contiguous rows from arbitrary columns of a 2-dimensional matrix-like object, and the current implementation really shines here (perhaps, unsurprisingly). Short term, my plan is to submit fstArray to Bioconductor following the next CRAN release of fst; even with this somewhat limited features I think it will be useful. Longer term, I hope to use a more matrix/-like fst backend and even extend to multidimensional arrays. Obviously, native support for multidimensional arrays in fst would be a huge help to me. My (more ambitious) plan is to leverage https://github.com/fstpackage/fstlib/ and develop the array infrastructure myself. This would be a great learning opportunity, but rather ambitious from my point of view.
To return to the OpenMP issues, my current plan is to first wait for the imminent
I'll try to find time in this week to test these out. Thanks, |
Quick update:
Pete |
Hi @PeteHaitch, thanks for the update and a (small) relief that you can build from the command line, even with |
Okay, I think I'm getting close to the source of the problem. I was unable to reproduce the issue when calling any of Triggering the error tends to require a series of devtools commands called via Rstudio keyboard shortcuts. I haven't figured out the exact sequence. I'm going to propose submitting this as a bug report to RStudio. First, I will need to confirm that I can trigger it using the toy package you posted in #109 (comment) |
Hi @PeteHaitch, good find and nice theme by the way 👍. Yes, so it seems like an |
Following up on #109 (comment):
I can confirm this can be triggered by the toy package. I've posted to rstudio/rstudio#1920 |
Thanks @PeteHaitch, I'm curious to see if the RStudio people understand what is causing this problem! |
Marcus, Following up on your question from December 3 (sorry for the delay in getting back to you): When I unchecked the Roxygen option and then ran Joel |
I was able to capture a stack trace in RStudio, following the steps from @PeteHaitch at rstudio/rstudio#1920.
Potentially related issues:
This is the commit that worked around the associated issue in |
I think the issue comes down to the use of OpenMP within forked processes. There's a small discussion of potential issues here: https://bisqwit.iki.fi/story/howto/openmp/#OpenmpAndFork Basically, if you have a process that might call If I understand correctly, either the parent or the child processes may use OpenMP features, but not both. |
Hi @kevinushey, thanks for investigating that and for the references to relevant I studied the code in Good to learn that |
Just to be specific, RStudio launches R processes in the build pane through a fork -- for example, when you click the |
Yes, exactly, That fork should be detected with this code which sets the number of threads to one. That's basically the same setup as the fork protection in Thanks, I will study the problem and report if I have more information! |
Hi @kevinushey, the forking issues with the
pthread_atfork(&when_fork, NULL, NULL) that crashes RStudio when it launches a forked process (to call
Thanks for the information and helping to track down and fix the problem! |
Hi @eipi10, this fix should solve your issues as well, if you are still experiencing problem, please let me know! |
Awesome news! Thank you so much for investigating and taking the time to get a fix @MarcusKlik. |
Thanks very much for investigating and fixing this Marcus! |
No problem! (and being able to build packages with RStudio/macOS with |
I've been building a couple of packages to load various personal utility functions. While building and using the packages, I was having problems where R would crash at some point during the package updating process (
devtools::document()
,devtools::build()
, etc.), but after the crash I would be able to get one step farther in the updating process before a crash. But then after installing the package, R would crash either when I loaded the package or when I ran a function from the package. Or, sometimes, the package wouldn't crash, but even after loading it, R wouldn't recognize any functions from the package when I tried to run them.After some experimentation, it looks like importing
fst
is what is causing the crashes. Or, at least, not importingfst
stopped the crashes from happening. I can even usefst::read.fst(...)
inside functions in the package and avoid a crash, as long as I don't explicitly importfst
.I was able to replicate the crashing behavior by opening a new R Package project in RStudio. In this empty project I created one more file called
imports.r
containing the following code:After saving this file in the
R
folder and runningdevtools::document()
, RStudio crashes. If I open a regular R session and rundevtools::document()
R crashes. If I reopen the project in either R or RStudio I can rundevtools::document()
without a crash, but thendevtools::build()
results in a crash (or sometimes I can build, but thendevtools::install()
results in a crash).If I change
#' @import fst
to#' @import dplyr
(or any other package I've tried) then the crashing stops.I'm not sure why this problem is occurring, but I'd be happy to provide additional information. Just let me know. Below is the description file for my version of
fst
(this is a development version that I updated to a couple of weeks ago) and some details about my system. Also, I asked a question about this at StackOverflow 10 days ago, but haven't gotten any replies. I'll post an answer there soon about the cause and (hopefully) a resolution.Macbook Pro running OSX Sierra 10.12.6
R: 3.4.2
RStudio: 1.1.392
devtools: 1.13.4
The text was updated successfully, but these errors were encountered: