[Rd] Segfault in setMask in R 4.1

Mike Lee Williams m|ke @end|ng |rom m|ke@p|@ce
Tue Sep 21 18:52:12 CEST 2021

Thank you! Here is the output of option("devices"), which I think means we're using Cairo:

    function (width = 1280, height = 960, pointsize = 24, units = "px", 
        bg = "white", dpi = 160, ...) 
        devSym <- basename(tempfile(pattern = "SensePlot", tmpdir = ""))
        newDev <- Cairo(width = width, height = height, pointsize = pointsize, 
            bg = bg, units = units, dpi = dpi, type = "raster", ...)
        attr(newDev, "units") <- units
        attr(newDev, "dpi") <- dpi
        assign(devSym, newDev, SenseDevices)
    <bytecode: 0x55b08ba031c0>
    <environment: namespace:Cairo>

"Sense" is the internal name of our application. I'm not sure what "devSym" and "newDev" are, but If there are no known issues with Cairo itself then our own code is presumably part of the problem.

I would like to confirm that by failing to reproduce the bug in "vanilla" R 4.1 with a Cairo device. If anyone has any tips for how to do that (on Linux) or any other comments I would be very grateful.

If our code is the problem then I'm still confused why a regular plot() works, but a ggplot2 qplot() segfaults. Maybe this is a clue!

I will post again if I figure anything out!


On Tue, Sep 21, 2021, at 3:37 AM, GILLIBERT, Andre wrote:
> Hello,
> Which graphic device (backend) do you use?
> The setMask() function calls the internal setMask function associated 
> to the graphic device.
> If the Web application uses one of the standard graphic backend, the 
> bug may come from the R core. If it uses a custom graphic backend, the 
> bug may be in the backend.
> -- 
> Sincerely
> ATTENTION: Cet e-mail provient d’une adresse mail extérieure au CHU de 
> Rouen. Ne cliquez pas sur les liens ou n'ouvrez pas les pièces jointes 
> à moins de connaître l'expéditeur et de savoir que le contenu est sûr. 
> En cas de doute, transférer le mail à « DSI, Sécurité » pour analyse. 
> Merci de votre vigilance
> I have inherited a build of R. We compile R from source and then use a custom
> web application to allow users to enter R statements and render the output (it's
> kind of like RStudio although the UX is quite different).
> Things were going fine until I tried to upgrade to R 4.1.x. The build succeeds,
> but I get the following segfault when I make qplot (ggplot2) calls:
>      *** caught segfault ***
>     address (nil), cause 'memory not mapped'
>     Traceback:
>      1: .setMask(NULL, NULL)
>      2: resolveMask.NULL(NULL)
>      3: (function (path) {    UseMethod("resolveMask")})(NULL)
>      4: grid.newpage()
>      5: print.ggplot(x)
>      6: (function (x, ...) UseMethod("print"))(x)
> I am not an R developer, so I don't really know how to read this. I am wondering
> if this is a known issue or if anyone has any suggestions. Here's some things
> I've tested:
> - I get the same segfault in R 4.1.0 and R 4.1.1. I do not get this error in R
>   4.0.4 or R 4.0.5.
> - The problem appears to be specific to the (graphics?) features of R that
>   ggplot2 uses. I do not get a segfault if I do a generic `plot(c(1,2,3))`.
> - I have tried versions of ggplot2 3.3.3 and 3.3.5.
> - The traceback points to files that were introduced in this commit
> https://github.com/wch/r-source/commit/16755bcddffe0cb4238d8a4979387d92b93a8324#diff-5c63f74229830cdde7886a50bf06dafcdf1d5b3d42cfa06b26814876e58c5ab0
> I am not an R user or R developer so I'm a bit stuck here. I would be happy to
> give the output of any commands. If anyone has any suggestions then please let
> me know!
> Thanks!
> Mike Lee Williams
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list