Skip to content
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

shift crashes R when using n = "lead" #3354

Closed
SymbolixAU opened this issue Feb 5, 2019 · 2 comments · Fixed by #3355
Closed

shift crashes R when using n = "lead" #3354

SymbolixAU opened this issue Feb 5, 2019 · 2 comments · Fixed by #3355
Assignees
Milestone

Comments

@SymbolixAU
Copy link

SymbolixAU commented Feb 5, 2019

While I'm aware this is incorrect use of the shift function, but if you forget to specify the type argument and use shift(val, "lead"), this causes Rstudio to crash.

Reproducible example

library(data.table)

dt <- data.table(
  id = 1:5
  , val = letters[1:5]
)

## This will crash RStudio
dt[, new_col := shift(val, "lead")]

## the fix is to specify `type = "lead"`
dt[, new_col := shift(val, type = "lead")]

Session info

devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 os       macOS  10.14.1              
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_AU.UTF-8                 
 ctype    en_AU.UTF-8                 
 tz       Australia/Melbourne         
 date     2019-02-05Packages ────────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version date       lib source                                
   assertthat    0.2.0   2017-04-11 [2] CRAN (R 3.5.0)                        
   backports     1.1.2   2017-12-13 [2] CRAN (R 3.5.0)                        
   callr         2.0.3   2018-04-11 [2] CRAN (R 3.5.0)                        
   cli           1.0.1   2018-09-25 [1] CRAN (R 3.5.0)                        
   crayon        1.3.4   2017-09-16 [2] CRAN (R 3.5.0)                        
   curl          3.3     2019-01-10 [1] CRAN (R 3.5.2)                        
 V data.table  * 1.12.0  2019-02-05 [1] Github (Rdatatable/data.table@e043dd2)
   debugme       1.1.0   2017-10-22 [2] CRAN (R 3.5.0)                        
   desc          1.2.0   2018-05-01 [2] CRAN (R 3.5.0)                        
   devtools      2.0.1   2018-10-26 [1] CRAN (R 3.5.0)                        
   digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.0)                        
   fs            1.2.6   2018-08-23 [1] CRAN (R 3.5.0)                        
   glue          1.3.0   2018-07-17 [2] CRAN (R 3.5.0)                        
   magrittr      1.5     2014-11-22 [2] CRAN (R 3.5.0)                        
   memoise       1.1.0   2017-04-21 [2] CRAN (R 3.5.0)                        
   pkgbuild      1.0.2   2018-10-16 [1] CRAN (R 3.5.0)                        
   pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.5.0)                        
   prettyunits   1.0.2   2015-07-13 [2] CRAN (R 3.5.0)                        
   R6            2.3.0   2018-10-04 [1] CRAN (R 3.5.0)                        
   Rcpp          1.0.0   2018-11-07 [1] CRAN (R 3.5.0)                        
   remotes       2.0.2   2018-10-30 [1] CRAN (R 3.5.0)                        
   rlang         0.3.1   2019-01-08 [1] CRAN (R 3.5.2)                        
   rprojroot     1.3-2   2018-01-03 [2] CRAN (R 3.5.0)                        
   rstudioapi    0.8     2018-10-02 [1] CRAN (R 3.5.0)                        
   sessioninfo   1.1.0   2018-09-25 [1] CRAN (R 3.5.0)                        
   testthat      2.0.0   2017-12-13 [2] CRAN (R 3.5.0)                        
   usethis       1.4.0   2018-08-14 [1] CRAN (R 3.5.0)                        
   withr         2.1.2   2018-03-15 [2] CRAN (R 3.5.0)                        

[1] /Users/david/Library/R/3.5/library
[2] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

 V ── Loaded and on-disk version mismatch.
@SymbolixAU SymbolixAU changed the title shift crashes when using n = "lead" shift crashes RStudio when using n = "lead" Feb 5, 2019
@jangorecki jangorecki self-assigned this Feb 5, 2019
@jangorecki
Copy link
Member

jangorecki commented Feb 5, 2019

@SymbolixAU could you also provide utils::sessionInfo() output? The above one looks corrupted at first glance:

data.table * 1.12.0 2019-02-05 [1] Github (Rdatatable/data.table@e043dd2)

e043dd2 is not 1.12.0 but 1.12.1

@jangorecki jangorecki added this to the 1.12.2 milestone Feb 5, 2019
jangorecki added a commit that referenced this issue Feb 5, 2019
@jangorecki jangorecki changed the title shift crashes RStudio when using n = "lead" shift crashes R when using n = "lead" Feb 5, 2019
@SymbolixAU
Copy link
Author

SymbolixAU commented Feb 5, 2019

@jangorecki sure thing

This is the sessioninfo() when I ran the original code

utils::sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.1

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] data.table_1.12.1    microbenchmark_1.4-4

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 

I've updated to the latest release and get the same error

remove.packages("data.table")
install.packages("data.table", type = "source",
                 repos = "http://Rdatatable.github.io/data.table")

library(data.table)

dt <- data.table(
  id = 1:5
  , val = letters[1:5]
)

## This will crash RStudio
dt[, new_col := shift(val, "lead")]

devtools::session_info(pkgs = "data.table")
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 os       macOS  10.14.1              
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_AU.UTF-8                 
 ctype    en_AU.UTF-8                 
 tz       Australia/Melbourne         
 date     2019-02-06Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package    * version date       lib source
 data.table * 1.12.1  2019-02-05 [1] local 

[1] /Users/david/Library/R/3.5/library
[2] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant