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

arm64 - caught segfault - shiny app #116

Closed
Polkas opened this issue Sep 6, 2022 · 8 comments
Closed

arm64 - caught segfault - shiny app #116

Polkas opened this issue Sep 6, 2022 · 8 comments

Comments

@Polkas
Copy link

Polkas commented Sep 6, 2022

I find out that the ragg is causing the shiny crashes on my arm64.
The error seems to come from https://github.com/rstudio/shiny/blob/d4527cdc289c897b92a0b06eef4200537c0d98b1/R/imageutils.R#L1-L12.
When I remove the ragg package from the R env, then the shiny app works correctly.
Of course reinstalling of the ragg is not helping.

Error message from the shiny app:

*** caught segfault ***
address 0xc0005ffe836b8040, cause 'invalid permissions'

Traceback:
 1: (function (filename = "Rplot%03d.png", width = 480, height = 480,     units = "px", pointsize = 12, background = "white", res = 72,     scaling = 1, bitsize = 8, bg) {    if (environmentName(parent.env(parent.frame())) == "knitr" &&         deparse(sys.call(), nlines = 1, width.cutoff = 500) ==             "dev(filename = filename, width = dim[1], height = dim[2], ...)") {        units <- "in"    }    file <- validate_path(filename)    if (!bitsize %in% c(8, 16)) {        stop("Only 8 and 16 bit is supported", call. = FALSE)    }    dim <- get_dims(width, height, units, res)    background <- if (missing(bg))         background    else bg    .Call("agg_png_c", file, dim[1], dim[2], as.numeric(pointsize),         background, as.numeric(res), as.numeric(scaling), as.integer(bitsize),         PACKAGE = "ragg")    invisible()})(filename = "/var/folders/ym/kndydf1d4lz25qklb25kqmz80000gn/T//RtmpUGIyib/file10cdf1cecf5db.png",     width = numeric(0), height = numeric(0), res = 158.4)
 2: do.call(pngfun, args)
 3: startPNG(outfile, width * pixelratio, height * pixelratio, res = res *     pixelratio, ...)
 4: drawPlot(name = "teal-main_ui-root-adverse_events-ae_by_subgroup-out-plot_main",     session = <environment>, func = function ()     {        ..stacktraceon..(renderPlot())    }, width = NULL, height = NULL, alt = NA, pixelratio = 2.2,     res = 72)

sessionInfo:

R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] C/UTF-8/C/C/C/C

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

other attached packages:
[1] ragg_1.2.2  shiny_1.7.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        digest_0.6.29     later_1.3.0       mime_0.12        
 [5] R6_2.5.1          lifecycle_1.0.1   xtable_1.8-4      magrittr_2.0.3   
 [9] rlang_1.0.5       cli_3.3.0         promises_1.2.0.1  ellipsis_0.3.2   
[13] textshaping_0.3.6 httpuv_1.6.5      fastmap_1.1.0     compiler_4.2.1   
[17] systemfonts_1.0.4 htmltools_0.5.3  
> 
> 
@thomasp85
Copy link
Member

Can you provide me with the means to reproduce this locally (on arm64). If not I'll not be able to debug the issue

@Polkas
Copy link
Author

Polkas commented Sep 6, 2022

Sorry, It is very hard to reproduce it with the base shiny (simplified code). Feel free to close it. At least we have a record which could be find by others, and then possibly more investigation applied.

@Polkas
Copy link
Author

Polkas commented Sep 7, 2022

looks to be linked with #82

@Polkas
Copy link
Author

Polkas commented Sep 7, 2022

ragg::agg_png(res = NULL, units = 'in') will crash the R session, 80 percent is connected with my problem will check it further

> ragg::agg_png(res = NULL, units = 'in')

 *** caught segfault ***
address 0xc0005ffe80dddb20, cause 'invalid permissions'

Traceback:
 1: ragg::agg_png(res = NULL, units = "in")
An irrecoverable exception occurred. R is aborting now ...
zsh: segmentation fault  R -e "ragg::agg_png(res = NULL, units = 'in')"

EDIT

and other arguments could not be NULL too, like width and height

@thomasp85
Copy link
Member

Thanks - I may not check the red correctly before passing it into the C code

@Polkas
Copy link
Author

Polkas commented Sep 7, 2022

The same for other arguments width and height, NULL will crash the R session such value is possible in shiny.

@cpsievert
Copy link

Hi @Polkas, do you happen to have reprex of a Shiny app that results on this error?

@Polkas
Copy link
Author

Polkas commented Nov 18, 2022

With simplified scope:

options(shiny.useragg = TRUE);shiny:::startPNG(tempfile(), NULL, NULL, NULL)

In my original app I think it is connected with rstudio/shiny#3637
The app is based on the framework build on shiny, https://github.com/insightsengineering/teal
It will not be easy to investigate it from such perspective.

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