ragg icon indicating copy to clipboard operation
ragg copied to clipboard

arm64 - caught segfault - shiny app

Open Polkas opened this issue 1 year ago • 6 comments

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  
> 
> 

Polkas avatar Sep 06 '22 17:09 Polkas

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

thomasp85 avatar Sep 06 '22 18:09 thomasp85

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 avatar Sep 06 '22 20:09 Polkas

looks to be linked with https://github.com/r-lib/ragg/issues/82

Polkas avatar Sep 07 '22 08:09 Polkas

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

Polkas avatar Sep 07 '22 09:09 Polkas

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

thomasp85 avatar Sep 07 '22 10:09 thomasp85

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

Polkas avatar Sep 07 '22 10:09 Polkas