Rdatatable / data.table

R's data.table package extends data.frame:
http://r-datatable.com
Mozilla Public License 2.0
3.58k stars 977 forks source link

Incredibly complicated Error message : Error: C stack usage 7970948 is too close to the limit #5282

Closed sanjmeh closed 2 years ago

sanjmeh commented 2 years ago
as.data.table(mean)

Error: C stack usage 7970948 is too close to the limit

as.data.table() returns an incredibly complicated error sending people into a tizzy if you pass any function to it by mistake. The above error message should be reserved for deep recursion or any memory stack overflow. It is certainly coming from C.

Perhaps we can just trap the input (if a function type) and return a more relevant error, like:

as.data.table needs a matrix or a data.frame as input

# Output of sessionInfo()

R version 4.0.1 (2020-06-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] factoextra_1.0.7         gmailr_1.0.1             bsplus_0.1.2             shinyalert_2.0.0         shinyjs_2.0.0            bslib_0.3.0             
 [7] shinycssloaders_1.0.0    shinyTime_1.0.1          npreg_1.0-6              rhandsontable_0.3.8      DataEditR_0.1.3          FinCal_0.6.3            
[13] timetk_2.6.1             slider_0.2.2             party_1.3-7              strucchange_1.5-2        sandwich_3.0-1           modeltools_0.2-23       
[19] mvtnorm_1.1-1            scales_1.1.1             rvest_1.0.1              ClusterR_1.2.5           gtools_3.9.2             plotly_4.10.0           
[25] RColorBrewer_1.1-2       ggrepel_0.9.1            janitor_2.1.0            forecast_8.15            forcats_0.5.1            ggplot2_3.3.5           
[31] tidyverse_1.3.1          splitstackshape_1.4.8    gt_0.3.1                 tictoc_1.0.1             crayon_1.4.1             xts_0.12.1              
[37] zoo_1.8-9                htmltools_0.5.2          stringr_1.4.0            htmlTable_2.2.1          tibble_3.1.4             xml2_1.3.2              
[43] jsonlite_1.7.2           tidyr_1.1.3              readr_2.0.2              httr_1.4.2               markdown_1.1             DT_0.19                 
[49] logger_0.2.0             shinyWidgets_0.6.2       dygraphs_1.1.1.6         magrittr_2.0.1           shinydashboardPlus_2.0.3 purrr_0.3.4             
[55] dplyr_1.0.7              data.table_1.14.0        shinydashboard_0.7.1     shiny_1.6.0              lubridate_1.7.10        

loaded via a namespace (and not attached):
  [1] utf8_1.1.4         tidyselect_1.1.1   htmlwidgets_1.5.4  gmp_0.6-2.1        pROC_1.18.0        munsell_0.5.0      codetools_0.2-16  
  [8] dials_0.0.10       future_1.22.1      miniUI_0.1.1.1     withr_2.4.1        colorspace_1.4-1   knitr_1.31         rstudioapi_0.13   
 [15] TTR_0.24.2         listenv_0.8.0      DiceDesign_1.9     parallelly_1.28.1  vctrs_0.3.8        generics_0.1.0     TH.data_1.0-10    
 [22] ipred_0.9-12       xfun_0.26          R6_2.5.1           RJSONIO_1.3-1.6    bitops_1.0-6       lhs_1.1.3          assertthat_0.2.1  
 [29] promises_1.1.1     multcomp_1.4-17    nnet_7.3-14        gtable_0.3.0       Bolstad_0.2-41     globals_0.14.0     timeDate_3043.102 
 [36] rlang_0.4.12       workflows_0.2.3    splines_4.0.1      lazyeval_0.2.2     gargle_1.2.0       yardstick_0.0.8    shinyBS_0.61      
 [43] broom_0.7.9        checkmate_2.0.0    yaml_2.2.1         reshape2_1.4.4     modelr_0.1.8       backports_1.1.7    httpuv_1.5.4      
 [50] quantmod_0.4.18    tools_4.0.1        lava_1.6.10        ellipsis_0.3.2     jquerylib_0.1.3    Rcpp_1.0.7         parsnip_0.1.7     
 [57] plyr_1.8.6         base64enc_0.1-3    RCurl_1.98-1.5     rpart_4.1-15       fracdiff_1.5-1     haven_2.3.1        fs_1.5.0          
 [64] furrr_0.2.3        warp_0.2.0         lmtest_0.9-38      reprex_2.0.1       GPfit_1.0-8        packrat_0.5.0      matrixStats_0.58.0
 [71] hms_1.1.1          mime_0.9           xtable_1.8-4       readxl_1.3.1       compiler_4.0.1     later_1.1.0.1      tzdb_0.1.2        
 [78] libcoin_1.0-8      DBI_1.1.0          dbplyr_2.1.1       MASS_7.3-51.6      Matrix_1.2-18      cli_3.0.1          quadprog_1.5-8    
 [85] parallel_4.0.1     gower_0.2.2        pkgconfig_2.0.3    coin_1.4-1         recipes_0.1.16     foreach_1.5.1      hardhat_0.1.6     
 [92] prodlim_2019.11.13 snakecase_0.11.0   digest_0.6.27      cellranger_1.1.0   curl_4.3           urca_1.3-0         lifecycle_1.0.0   
 [99] nlme_3.1-147       tseries_0.10-48    viridisLite_0.4.0  tune_0.1.6         fansi_0.4.1        pillar_1.6.2       lattice_0.20-41   
[106] fastmap_1.1.0      survival_3.1-12    glue_1.5.0         shinythemes_1.2.0  iterators_1.0.13   class_7.3-17       stringi_1.7.4     
[113] sass_0.4.0         rsample_0.1.0      future.apply_1.8.1
HughParsonage commented 2 years ago

Not reproducible.

$ R -q --vanilla -e "data.table::as.data.table(mean)"
> data.table::as.data.table(mean)
Error in as.data.frame.default(x, ...) :
  cannot coerce class '"function"' to a data.frame
Calls: <Anonymous> ... as.data.table -> as.data.frame -> as.data.frame.default
Execution halted

I note you have other packages attached which are likely at least part of the reason you are getting the arcane error message. I tried attaching a few of them but could not reproduce. If you're able to narrow down a minimal number of packages which when attached trigger your error (and you can't see anything obvious wrong with the packages themselves), feel free to reopen.

sanjmeh commented 2 years ago

All right, so if it is not replicable then it must be a package clash. Strange though as it is a single function use case.

MichaelChirico commented 2 years ago

please update data.table -- I believe you're experiencing a known bug that's been fixed