From p.murrell at auckland.ac.nz  Sun Oct  3 23:23:39 2010
From: p.murrell at auckland.ac.nz (Paul Murrell)
Date: Mon, 04 Oct 2010 10:23:39 +1300
Subject: [Rd] strange interaction between rasterImage and Grid graphics
In-Reply-To: <58dc2267d949738dc9a098ff54e26482@braverock.com>
References: <AANLkTimX=5B478CCrEjCX0Y0Kw-FVuu=6ED5kYQ0iykY@mail.gmail.com>
	<4CA7C1D8.7050202@auckland.ac.nz>
	<AANLkTikY-erfsxifHcKyPcnrCnwaiTn5K3s9KTvcfht4@mail.gmail.com>
	<58dc2267d949738dc9a098ff54e26482@braverock.com>
Message-ID: <4CA8F45B.8080406@auckland.ac.nz>

Hi

Thanks for narrowing down the problem.

I have committed some more defensive code and a change that fixes the 
problem (for me ...

R version 2.13.0 Under development (unstable) (2010-09-28 r53056)
Platform: i686-pc-linux-gnu (32-bit)

Paul

On 10/3/2010 10:25 PM, Brian G. Peterson wrote:
> On Sat, 2 Oct 2010 22:36:07 -0700, Deepayan Sarkar
> <deepayan.sarkar at gmail.com>  wrote:
>>> On Sat, Oct 2, 2010 at 4:35 PM, Paul Murrell<p.murrell at auckland.ac.nz>
>>> wrote:
>>>> The only device I've tried is quartz(), x11() crashed with
> rasterImage,
>>>
>>> That is more serious.  I have heard of a couple of others like this and
>>> I think the common thread may be 64-bit MacOS X.
>>> I need to get access to such a beast to take a look.
>>
>> Or maybe just 64 bit. I have (running Debian unstable)
>>
>>> sessionInfo()
>> R version 2.12.0 Under development (unstable) (2010-09-02 r52864)
>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>
>> and I get reproducible crashes (same 'memory not mapped' segfault) with
>>
>> x11(type="Xlib")
>> example(rasterImage) #or
>>
>> library(lattice)
>> example(panel.levelplot.raster)
>>
>> [I noticed this a while back, but neglected to report.]
>>
>> -Deepayan
>>
>>>
>>> Paul
>>>
>>>>   *** caught segfault ***
>>>> address 0x28, cause 'memory not mapped'
>>>>
>>>> Traceback:
>>>>   1: rasterImage(matrix(1), 1, 1, 1, 1)
>>>>
>>>> sessionInfo()
>>>> R version 2.11.1 (2010-05-31)
>>>> x86_64-apple-darwin9.8.0
>
> I can confirm the problem exists in 2.11.1 as well on 64 bit Ubuntu:
>
> R version 2.11.1 (2010-05-31)
>
>> x11(type="Xlib")
>> example(rasterImage)
>
> rstrIm>  require(grDevices)
>
> rstrIm>  ## set up the plot region:
> rstrIm>  op<- par(bg = "thistle")
>
> rstrIm>  plot(c(100, 250), c(300, 450), type = "n", xlab="", ylab="")
> Hit<Return>  to see next plot:
>
> rstrIm>  image<- as.raster(matrix(0:1, ncol=5, nrow=3))
>
> rstrIm>  rasterImage(image, 100, 300, 150, 350, interpolate=FALSE)
>
>   *** caught segfault ***
> address 0x28, cause 'memory not mapped'
>
> Traceback:
>   1: rasterImage(image, 100, 300, 150, 350, interpolate = FALSE)
>   2: eval.with.vis(expr, envir, enclos)
>   3: eval.with.vis(ei, envir)
>   4: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
> getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
> getOption("continue"), sep = ""), verbose = verbose, max.deparse.length =
> Inf,     encoding = encoding, skip.echo = skips, keep.source = TRUE)
>   5: example(rasterImage)
>
> The lattice example in Deepyan's email
>
> library(lattice)
> example(panel.levelplot.raster)
>
> works for me in 2.11.1
>
> Regards,
>
>     - Brian
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> x86_64-pc-linux-gnu
>
> locale:
>   [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>   [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>   [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>   [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>   [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grid      stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] lattice_0.19-11
>
> loaded via a namespace (and not attached):
> [1] tools_2.11.1
>
>

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



[Rd] strange interaction between rasterImage and Grid graphics
Paul Murrell