facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.49k stars 4.53k forks source link

Caught segfault error #1601

Closed jroberayalas closed 4 years ago

jroberayalas commented 4 years ago

I'm running a code that relies on the Prophet library, but when I want to predict using a trained model, I get a "caught segfault error". Any help on how to solve this? I've remove/reinstalled the prophet library already without any success.

 *** caught segfault ***
address 0x12cf90ffc, cause 'memory not mapped'
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation

Traceback:
1: pmax(abs(as.integer(width)), if (format == "fg" || format == "f") { xEx <- as.integer(floor(log10(abs(x + (x == 0))))) as.integer(x < 0 | flag != "") + digits + if (format == "f") { 2L + pmax(xEx, 0L) } else { 1L + pmax(xEx, digits, digits + (-xEx) + 1L) + length(nf) }} else rep.int(digits + 8L, n))
2: formatC(x, format = "fg", width = 1, digits = digits)
3: paste0(if (use.fC) formatC(x, format = "fg", width = 1, digits = digits) else format(x, trim = TRUE, digits = digits, ...), "%")
4: format_perc(probs)
5: quantile.default(newX[, i], ...)
6: FUN(newX[, i], ...)
7: apply(comp, 1, stats::quantile, lower.p, na.rm = TRUE)
8: predict_seasonal_components(object, df)
9: predict.prophet(m, all_data)
10: predict(m, all_data)
11: eval(statements[[idx]], envir = sourceEnv)
12: eval(statements[[idx]], envir = sourceEnv)
13: sourceWithProgress(script = "/Users/josolare/Documents/workspace/src/LRpR/backcaster.R", encoding = "UTF-8", con = stdout(), importRdata = NULL, exportRdata = NULL)
An irrecoverable exception occurred. R is aborting now ...

The sessionInfo is shown below:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.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/4.0/Resources/lib/libRlapack.dylib

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     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        urca_1.3-0        pillar_1.4.6      compiler_4.0.2   
 [5] tseries_0.10-47   tools_4.0.2       xts_0.12-0        nlme_3.1-148     
 [9] lubridate_1.7.9   lifecycle_0.2.0   tibble_3.0.3      gtable_0.3.0     
[13] lattice_0.20-41   pkgconfig_2.0.3   rlang_0.4.7       DBI_1.1.0        
[17] rstudioapi_0.11   curl_4.3          parallel_4.0.2    dplyr_1.0.0      
[21] generics_0.0.2    vctrs_0.3.2       imputeTS_3.0      lmtest_0.9-37    
[25] grid_4.0.2        nnet_7.3-14       forecast_8.12     tidyselect_1.1.0 
[29] glue_1.4.1        R6_2.4.1          tidyr_1.1.0       TTR_0.23-6       
[33] ggplot2_3.3.2     purrr_0.3.4       magrittr_1.5      scales_1.1.1     
[37] ellipsis_0.3.1    quantmod_0.4.17   timeDate_3043.102 colorspace_1.4-1 
[41] fracdiff_1.5-1    quadprog_1.5-8    stinepack_1.4     munsell_0.5.0    
[45] crayon_1.3.4      zoo_1.8-8
jroberayalas commented 4 years ago

I have removed and reinstalled prophet using install.packages('prophet'), but then I get the following error:

> library(prophet)
Loading required package: Rcpp
Loading required package: rlang

Attaching package: ‘rlang’

The following objects are masked from ‘package:purrr’:

    %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int,
    flatten_lgl, flatten_raw, invoke, list_along, modify, prepend,
    splice

Error: package or namespace load failed for ‘prophet’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so, 6): Library not loaded: @rpath/libtbb.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/prophet/libs/prophet.so
  Reason: image not found
bletham commented 4 years ago

For the segfault: I've seen rare segfaults during model fitting when there are numerical issues due to poor model identifiability, but I've never seen a segfault during predict. Is there any chance you're able share code/data that reproduces the issue? How many rows are in the future dataframe being passed to predict?

For the install issue: I'm not sure about this one either. Could you try removing it and installing from source, like

install.packages("prophet", type="source")

It looks like something got messed up with the compiled model and it isn't where R expects it to be.

hideaki commented 4 years ago

On Mac, I'm seeing very similar stack trace.

 *** caught segfault ***
address 0x10f1adffc, cause 'memory not mapped'
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
... Repetition of the same rows here ...
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation

Traceback:
 1: paste0(if (use.fC) formatC(x, format = "fg", width = 1, digits = digits) else format(x,     trim = TRUE, digits = digits, ...), "%")
 2: format_perc(probs)
 3: quantile.default(newX[, i], ...)
 4: FUN(newX[, i], ...)
 5: apply(comp, 1, stats::quantile, lower.p, na.rm = TRUE)
 6: predict_seasonal_components(object, df)
 7: predict.prophet(m, future)
 8: stats::predict(m, future)
... Our application layer call stacks here...

sessionInfo output:

> sessionInfo()
R version 4.0.1 (2020-06-06)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

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] prophet_0.6.1       rlang_0.4.7         Rcpp_1.0.5         
[4] exploratory_6.1.2.1 dplyr_1.0.1        

loaded via a namespace (and not attached):
 [1] pillar_1.4.6      compiler_4.0.1    anonymizer_0.2.2  plyr_1.8.6       
 [5] iterators_1.0.12  tools_4.0.1       nlme_3.1-148      lifecycle_0.2.0  
 [9] tibble_3.0.3      gtable_0.3.0      lattice_0.20-41   pkgconfig_2.0.3  
[13] psych_2.0.7       foreach_1.5.0     parallel_4.0.1    stringr_1.4.0    
[17] generics_0.0.2    vctrs_0.3.2       triebeard_0.3.0   grid_4.0.1       
[21] tidyselect_1.1.0  glue_1.4.1        data.table_1.13.0 R6_2.4.1         
[25] dtw_1.21-3        prediction_0.3.14 ggplot2_3.3.2     purrr_0.3.4      
[29] reshape2_1.4.4    tidyr_1.1.1       magrittr_1.5      urltools_1.7.3   
[33] scales_1.1.1      backports_1.1.8   codetools_0.2-16  ellipsis_0.3.1   
[37] mnormt_2.0.1      colorspace_1.4-1  proxy_0.4-24      stringi_1.4.6    
[41] munsell_0.5.0     tmvnsim_1.0-2     broom_0.7.0       crayon_1.3.4     
[45] zoo_1.8-8        

Trying source build, but I have not been able to successfully build yet so far.

hideaki commented 4 years ago

On my environment, it seems this only happens with tibble 3.0.2 or later. It does not happen with tibble 3.0.1.

bletham commented 4 years ago

@seanjtaylor ran into some segfaults when packages hadn't been upgrade for a while, and found that devtools::clean_dll fixed it.