[Rd] Patch: fix segfault from empty raster
Paul Murrell
paul at stat.auckland.ac.nz
Tue Sep 24 05:04:45 CEST 2013
Hi
Protecting against empty rasters seems like a good idea(!)
Thanks for the report.
Could you please try sending me your suggested patch directly?
(it did not make it through via r-devel)
Paul
On 09/16/13 22:24, QRD wrote:
> Hi,
>
> A colleague recently came across an R crash, which I can boil down to
> the following, running under Rgui on Windows 7:
>
> library(ggplot2)
> ggplot(data.frame(x=1, y=1, z=4.7), aes(x, y, z=z)) + stat_summary2d()
>
> This reliably causes a segmentation fault. sessionInfo() below.
>
> What's happening is that (for reasons which I'll discuss with the
> ggplot2 developers) the 'colorbar' guide is being built with a zero-size
> source raster.
>
> In L_raster() (grid.c), this raster is not a "nativeRaster", so we do
>
> image = (unsigned int*) R_alloc(n, sizeof(unsigned int));
>
> with n = 0, and R_alloc() gives us a NULL pointer.
>
> The display of this raster requests interpolation, so we end up in
> R_GE_rasterInterpolate(), where 'sraster' is NULL, and chaos ensues as
> it tries to read source pixels.
>
> It seems to me that it doesn't make sense to display an empty raster, so
> I inserted a check in L_raster(). A proof-of-concept patch is attached.
> With this patch, R gives an error message instead of a segfault.
>
> Does this seem a sensible change? If so, could something like it be
> incorporated?
>
> Thanks,
>
> Ben.
>
> - - - - 8< - - - -
>
>> sessionInfo()
> R version 3.0.1 (2013-05-16)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_Ireland.1252 LC_CTYPE=English_Ireland.1252
> [3] LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C
> [5] LC_TIME=English_Ireland.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] ggplot2_0.9.3.1
>
> loaded via a namespace (and not attached):
> [1] colorspace_1.2-2 compiler_3.0.1 dichromat_2.0-0 digest_0.6.3
> [5] grid_3.0.1 gtable_0.1.2 labeling_0.2 MASS_7.3-26
> [9] munsell_0.4 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5
> [13] reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.1
>
>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-devel
mailing list