Segfault with bridgesampling

Hi,
bridgesampling package suddenly stopped working giving an awful segfault even with a tiny dataset, I’m not sure what changed, but it’s not the rstan version or brms or bridgesampling…

This is the data and code. I’m here showing it with brms, but I also tried to use rstan directly and I get the same segfault.

#data
structure(list(F = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("F1", 
"F2"), class = "factor"), pDV = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 
1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 
1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L), id = 1:100), row.names = c(NA, 
-100L), class = c("tbl_df", "tbl", "data.frame"))

# Bayesian GLM: H0
fit_pDV_H0 <- brm(pDV ~ 1,
  data = df_BF,
  family = bernoulli(link = "logit"),
  prior = priors_logit1[-2, ],
  save_pars = save_pars(all = TRUE)
)
# Bridge sampling
mLL_binom_H0 <- bridge_sampler(fit_pDV_H0, silent = TRUE)

This is the error.

Traceback:
 1: .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: 0x55a0318515c0>,     dll = list(name = "Rcpp", path = "/home/bruno/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/libs/Rcpp.so",         dynamicLookup = TRUE, handle = <pointer: 0x55a03509af60>,         info = <pointer: 0x55a0309b38b0>), numParameters = -1L),     <pointer: 0x55a03ce61980>, <pointer: 0x55a03bc409f0>, .pointer,     ...)
 2: object@.MISC$stan_fit_instance$unconstrain_pars(pars)
 3: .local(object, ...)
 4: rstan::unconstrain_pars(stanfit_model, .rstan_relist(theta, skeleton))
 5: rstan::unconstrain_pars(stanfit_model, .rstan_relist(theta, skeleton))
 6: FUN(newX[, i], ...)
 7: apply(ex, 1:2, FUN = function(theta) {    rstan::unconstrain_pars(stanfit_model, .rstan_relist(theta,         skeleton))})
 8: bridge_sampler.stanfit(samples$fit, ...)
 9: bridge_sampler(samples$fit, ...)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
14: try(bridge_sampler(samples$fit, ...))
15: bridge_sampler.brmsfit(fit_pDV_H0, silent = TRUE)
16: bridge_sampler(fit_pDV_H0, silent = TRUE)

I’ve been using the dev version of rstan_2.21.3 for while now without problems. I’ve seen all sort of weird problems with the newest dev version so I’m hesitant to change it…
Is this a common problem solved in some rstan version? Or is there some package messing up rstan? (or should I open an issue?) I’ll greatly appreciate how I can manage to get bridgesampling working again!

Thanks,
Bruno

Complete session info

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages:
[1] bridgesampling_1.1-2 rstan_2.21.3         ggplot2_3.3.3       
[4] StanHeaders_2.21.0-7 bcogsci_0.0.0.9000   brms_2.16.1         
[7] Rcpp_1.0.7          

loaded via a namespace (and not attached):
  [1] nlme_3.1-149         matrixStats_0.58.0   xts_0.12.1          
  [4] threejs_0.3.3        tensorA_0.36.2       tools_4.0.3         
  [7] backports_1.2.1      utf8_1.2.2           R6_2.5.1            
 [10] DT_0.17              DBI_1.1.1            mgcv_1.8-36         
 [13] projpred_2.0.2       colorspace_2.0-2     withr_2.4.2         
 [16] prettyunits_1.1.1    tidyselect_1.1.1     gridExtra_2.3       
 [19] processx_3.5.2       Brobdingnag_1.2-6    curl_4.3.2          
 [22] compiler_4.0.3       cli_2.5.0            shinyjs_2.0.0       
 [25] colourpicker_1.1.0   posterior_1.0.1      scales_1.1.1        
 [28] dygraphs_1.1.1.6     checkmate_2.0.0      mvtnorm_1.1-2       
 [31] ggridges_0.5.3       callr_3.7.0          stringr_1.4.0       
 [34] digest_0.6.27        minqa_1.2.4          base64enc_0.1-3     
 [37] pkgconfig_2.0.3      htmltools_0.5.2      lme4_1.1-26         
 [40] fastmap_1.1.0        htmlwidgets_1.5.4    rlang_0.4.11        
 [43] rstudioapi_0.13      shiny_1.6.0          farver_2.1.0        
 [46] generics_0.1.0       jsonlite_1.7.2       zoo_1.8-8           
 [49] crosstalk_1.1.1      gtools_3.8.2         dplyr_1.0.5         
 [52] distributional_0.2.2 inline_0.3.17        magrittr_2.0.1      
 [55] loo_2.4.1            bayesplot_1.8.0.9000 Matrix_1.3-4        
 [58] munsell_0.5.0        fansi_0.5.0          abind_1.4-5         
 [61] lifecycle_1.0.0      stringi_1.7.4        MASS_7.3-54         
 [64] pkgbuild_1.2.0       plyr_1.8.6           grid_4.0.3          
 [67] parallel_4.0.3       promises_1.2.0.1     crayon_1.4.1        
 [70] miniUI_0.1.1.1       lattice_0.20-44      splines_4.0.3       
 [73] ps_1.6.0             pillar_1.6.1         igraph_1.2.6        
 [76] boot_1.3-28          markdown_1.1         shinystan_2.5.0     
 [79] codetools_0.2-18     reshape2_1.4.4       stats4_4.0.3        
 [82] rstantools_2.1.1     glue_1.4.2           V8_3.4.0            
 [85] RcppParallel_5.0.2   Rdpack_2.1.2         vctrs_0.3.8         
 [88] nloptr_1.2.2.2       httpuv_1.6.3         gtable_0.3.0        
 [91] purrr_0.3.4          assertthat_0.2.1     rbibutils_2.2.3     
 [94] mime_0.11            xtable_1.8-4         coda_0.19-4         
 [97] later_1.3.0          rsconnect_0.8.16     tibble_3.1.1        
[100] shinythemes_1.2.0    gamm4_0.2-6          statmod_1.4.35      
[103] ellipsis_0.3.2      
1 Like

Are you on Linux/Mac? Packages with C++ code (including rstan) on Linux/Mac may require reinstallation from source after you’ve updated some components your system, so I would try that. Since the main culprit appears to be rstan, I would then try to update rstan and only file an issue if you can reproduce the problem in latest version…

Hope you can get this resolved soon…

I’ve reinstalled everything, R, rstan, etc. And not it works, not sure what it was.

2 Likes