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

std::bad_function_call #4095

Open
vflorelo opened this issue Jul 10, 2024 · 6 comments
Open

std::bad_function_call #4095

vflorelo opened this issue Jul 10, 2024 · 6 comments

Comments

@vflorelo
Copy link

Incident

Whenever me or my team try to use a shiny app, rstudio-server crashes and restarts the session, the behaviour is similar if we try to run any shiny app from the command line, which shows the following error

terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call
Aborted

We are using Ubuntu 22.04, we noticed the incident started after updating all packages on 2024-06-30, but the bug might have been there previously. At the time, we were running R v4.3.2 and rstudio-server 2024.04.2-764.

We then updated R to v4.4.1, R was installed from source with the following flags for configure:

  • --enable-R-shlib
  • --with-tcltk

Except for system dependencies, none of the R packages were installed using apt or dpkg.

System details

Output of sessionInfo():

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/local/lib/R/lib/libRblas.so 
LAPACK: /usr/local/lib/R/lib/libRlapack.so;  LAPACK version 3.12.0

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

time zone: Europe/London
tzcode source: system (glibc)

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

loaded via a namespace (and not attached):
[1] compiler_4.4.1

Example application

#!/usr/local/bin/R
library("shiny")
shiny::devmode(TRUE)
ui <- fluidPage("Hello, world!")
server <- function(input, output, session) {}
shinyApp(ui, server)

Mitigation attempts

  1. We tried updating R to the newest version
  2. We tried updating shiny to the newest version
  3. We tried updating rstudio to the newest version
  4. We tried installing shiny from source

No errors were reported in any of the above

Googling "shiny" + "bad_function_call" did not return any significant results

Any help or pointers are greatly appreciated.

@gadenbuie
Copy link
Member

Hi @vflorelo, thanks for the report. It sounds like this might be an rstudio-server issue, but I'm not sure. Can you also include the output from devtools::session_info() in your issue? That function gives more information about your environment and the version of RStudio being used.

@vflorelo
Copy link
Author

vflorelo commented Jul 10, 2024

Dear @gadenbuie
Thank you very much for your promptly reply.
Here's the output of devtools::session_info()

> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.1 (2024-06-14)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_GB.UTF-8
 ctype    en_GB.UTF-8
 tz       Europe/London
 date     2024-07-10
 rstudio  2024.04.2+764 Chocolate Cosmos (server)
 pandoc   2.9.2.1 @ /usr/bin/pandoc

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.1)
 cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.1)
 devtools      2.4.5   2022-10-11 [1] CRAN (R 4.4.1)
 digest        0.6.36  2024-06-23 [1] CRAN (R 4.4.1)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.1)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.1)
 fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.1)
 glue          1.7.0   2024-01-09 [1] CRAN (R 4.4.1)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
 htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.4.1)
 httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.4.1)
 later         1.3.2   2023-12-06 [1] CRAN (R 4.4.1)
 lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.1)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.1)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.1)
 mime          0.12    2021-09-28 [1] CRAN (R 4.4.1)
 miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.4.1)
 pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.4.1)
 pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.4.1)
 profvis       0.3.8   2023-05-02 [1] CRAN (R 4.4.1)
 promises      1.3.0   2024-04-05 [1] CRAN (R 4.4.1)
 purrr         1.0.2   2023-08-10 [1] CRAN (R 4.4.1)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.1)
 Rcpp        * 1.0.12  2024-01-09 [1] CRAN (R 4.4.1)
 remotes       2.5.0   2024-03-17 [1] CRAN (R 4.4.1)
 rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.1)
 rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.1)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.1)
 shiny         1.8.1.1 2024-04-02 [1] CRAN (R 4.4.1)
 stringi       1.8.4   2024-05-06 [1] CRAN (R 4.4.1)
 stringr       1.5.1   2023-11-14 [1] CRAN (R 4.4.1)
 urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.4.1)
 usethis       2.2.3   2024-02-19 [1] CRAN (R 4.4.1)
 vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.1)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 4.4.1)

 [1] /usr/local/lib/R/site-library
 [2] /usr/local/lib/R/library

──────────────────────────────────────────────────────────────────────────────

Noteworthy, the shiny error also happens when I call the program from the R command line (outside rstudio) or if I execute it as a script with Rscript

Thank you again for your support

@gadenbuie
Copy link
Member

Noteworthy, the shiny error also happens when I call the program from the R command line (outside rstudio) or if I execute it as a script with Rscript

Oh interesting, that is noteworthy. I tried to reproduce the issue with Ubuntu via rocker, but couldn't. In the mitigation attempts section you mention "updating R to the newest version". Was that also installed from source? Can you install R from apt?

@vflorelo
Copy link
Author

I think I figured out what happened.
Timeline:

  • I removed my R installation from source.
  • I installed R 4.4.1 and shiny v1.5.0+dfsg-2 using apt. No errors whatsoever.
  • I ran BiocManager::install() as root and shiny broke again.
  • I removed everything and started from scratch again
  • I launched an infinite loop starting and stopping a simple shiny app, so that when the problematic package was installed, I was able to catch it

Since apt puts the installed packages in /usr/lib/R/site-packages, but BiocManager::install() and install.packages() place them in /usr/local/lib/R/site-packages, it was easy, but time consuming to find the problematic package.

The culprit: httpuv, the version installed when running install.packages("httpuv") (1.6.15) results in shiny complaining about the bad_function_call, whereas the version installed with apt (1.6.5+dfsg-1) works fine. I repeated this to make sure httpuv was the problematic package.

This bug(?) might be out of shiny's scope, so it might be worth closing this issue, but still worth checking if updates to httpuv cause similar issues to other users.

Thank you for your pointers and your help.
Best wishes. Vic.

@gadenbuie
Copy link
Member

gadenbuie commented Jul 17, 2024

httpuv, the version installed when running install.packages("httpuv") (1.6.15) results in shiny complaining about the bad_function_call, whereas the version installed with apt (1.6.5+dfsg-1) works fine. I repeated this to make sure httpuv was the problematic package.

Two interesting things stand out to me here. First httpuv 1.6.5 is relatively old (released Jan 2022). And second the +dfsg-1 suffix seems like an indication that the person who packaged httpuv for Ubuntu (really Debian) modified the package in some way, likely to avoid the issues you've encountered. It took me a bit of searching, but I found the repository where the apt package versions live: https://salsa.debian.org/r-pkg-team/r-cran-httpuv.

I guess my recommendation would be to install httpuv via apt if possible.

@jcheng5
Copy link
Member

jcheng5 commented Jul 17, 2024

Hmmmm, I use install.packages("httpuv") all the time on Ubuntu 22.04 without issue.

@vflorelo, do you know what CRAN mirror you were/are using? Just a normal one, or packagemanager.posit.co (which allows you to install prebuilt binary packages for Linux)?

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

No branches or pull requests

3 participants