[Rd] Error in grid.text after tcltk package loaded

Paul Murrell p.murrell at auckland.ac.nz
Wed Feb 6 02:16:02 CET 2008


Hi

This looks like a problem with some unPROTECTed memory that is getting
grabage collected.  A gpar object that is passed down is being corrupted.

I can make the problem go away by PROTECTing currentgp in gridText() (in
grid.c), but I can't see yet why that needs PROTECTing (if it really
does, then LOTS of similar variables also need PROTECTing).

Thanks for nailing the problem down Erik.

In case anyone else is investigating, I could explore this a little by
putting a gdb break in name2col() and then forcing redraws (resize or
reveal new parts of the window) until one of the redraws triggered the
'invalid color name' error.  (I couldn't see how to trap the 'REAL() can
only ...' errors.)

Paul


Erik Iverson wrote:
> 
> Erik Iverson wrote:
>> Hello -
>>
>> I am noticing some strange errors when using the grid package, but 
>> (apparently) only after loading the tcltk package.  The interaction here 
>> does not make sense to me, and I'm wondering if anyone else can 
>> reproduce this, or if it is specific to my setup.  Here is my sessionInfo:
>>
>> sessionInfo()
>> R version 2.6.2 RC (2008-02-04 r44332)
>> i686-pc-linux-gnu
>>
>> locale:
>> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] tcltk     grid      stats     graphics  grDevices utils     datasets
>> [8] methods   base
>>
>> This also happens to me in R 2.6.1. I'm running Linux (RHEL 4) on a 
>> 32-bit Intel CPU and using KDE.  These are R versions that I have 
>> compiled myself.
>>
>> I try the following in R (started with --vanilla), this is the simplest 
>> code I have to reproduce the problem on my end.
>>
>> ## Start R Code
>>
>> library(grid)
>> library(tcltk)
>> grid.text("a", x = seq(0,1, by = .001))
>>
>> ## End R Code
>>
>> The graphic draws to my X11 device, however, when I try to move the X11 
>> R Graphics Device window with my mouse and 'drop' it somewhere by 
>> releasing the mouse button, I get errors like the following:
>>
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : invalid color name
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : REAL() can only be applied to a 'numeric', not a 'NULL'
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : VECTOR_ELT() can only be applied to a 'list', not a 'integer'
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : REAL() can only be applied to a 'numeric', not a 'character'
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : REAL() can only be applied to a 'numeric', not a 'NULL'
>>  > Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, 
>>   : REAL() can only be applied to a 'numeric', not a 'char'
>> In addition: Warning message:
>> In grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x,  :
>>    supplied color is not numeric nor character
>>
>> My traceback always looks like this:
>>  > traceback()
>> 5: .Call.graphics(fnname, ..., PACKAGE = "grid")
>> 4: grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x,
>>         x$y, resolveHJust(x$just, x$hjust), resolveVJust(x$just,
>>             x$vjust), x$rot, x$check.overlap)
>> 3: drawDetails.text(x, recording = FALSE)
>> 2: drawDetails(x, recording = FALSE)
>> 1: drawGrob(x)
>>
>> I can only get these messages to happen after loading the tcltk package, 
>> using grid.text, with 'many' text strings (happens rarely with 100, 
>> almost every move with 1000 strings as in my example).
>>
>> I found just one reference to a similar error message in the archives, 
>> although not to do with grid. Here's a link:
>>
>> https://stat.ethz.ch/pipermail/r-devel/2008-January/048117.html
>>
>> Can anyone else replicate this? Any ideas on what's going on?
> 
> One more piece of information.  In Gnome, I noticed the messages only 
> when I'd drag the window part of the way off the visible desktop, and 
> then drag it back on and drop it.  You could see the X11 window 'flash' 
> white quickly and then redraw (sorry for imprecise terminology here).
> On KDE, I have it set to show the X11 geometry when moving windows, 
> which means it must 'redraw' for each move, since the geometry window 
> obscures the device contents.  Once I took off the geometry setting, I 
> had to drag the windows part of the way off the screen, and then back on 
> to cause this behavior.
> 
> 
>> Best,
>> Erik Iverson
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> 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