r-lib/ragg

grid graphics mask example causes a segfault in agg_png on Mac

Closed this issue · 0 comments

The following code causes a segmentation fault on my machine:

> library(ragg)
> agg_png()
> library(grid)
> grid.segments(gp=gpar(col=3, lwd=50))
> path <- gTree(children=gList(circleGrob(r=.4), 
+                              rectGrob(width=.4, height=.2)))
> grid.fill(path,
+           rule="evenodd",
+           gp=gpar(col=NA, fill=4))

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

Traceback:
 1: grid.Call.graphics(C_fill, path, .ruleIndex(x$rule))
 2: drawDetails.GridFill(x, recording = FALSE)
 3: drawDetails(x, recording = FALSE)
 4: drawGrob(x)
 5: recordGraphics(drawGrob(x), list(x = x), getNamespace("grid"))
 6: grid.draw.grob(fillGrob(...))
 7: grid.draw(fillGrob(...))
 8: grid.fill(path, rule = "evenodd", gp = gpar(col = NA, fill = 4))

It also causes RStudio to crash when using the "agg" graphics backend.

The source of this code is Paul Murrell's blog post.

Sessioninfo:

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

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

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

time zone: Europe/London
tzcode source: internal

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

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

Package versions:

> packageVersion("ragg")
[1] ‘1.2.6> packageVersion("grid")
[1] ‘4.3.2