From iverson at biostat.wisc.edu  Thu May 22 20:08:30 2008
From: iverson at biostat.wisc.edu (Erik Iverson)
Date: Thu, 22 May 2008 13:08:30 -0500
Subject: [Rd] grid error message when resizing graphics window after tcltk
	loaded
Message-ID: <4835B69E.3050705@biostat.wisc.edu>

Dear R-devel / Dr. Murrell  -

This is similar but ultimately unrelated (I think) to something I posted 
about in February.  See my original post here:

https://stat.ethz.ch/pipermail/r-devel/2008-February/048278.html

I start R with the --vanilla option, and run the following code.

## BEGIN SAMPLE R CODE

library(grid)
for(i in seq(0, 1, by = .1)) {
   for(j in seq(0, 1, by = .1)) {
     angle <- runif(1, 1, 180)
     col <- sample(colors(), 1)
     pushViewport(viewport(x = i, y= j, width = .1, height = .1,
                           angle = angle, gp = gpar(col = col)))
     grid.rect()
     popViewport()
   }
}

## END SAMPLE R CODE

I can then resize the resulting R Graphics Device window and everything 
seems to work fine.

If I then do issue 'library(tcltk)', and reissue the above code, and 
then resize the resulting window to something fairly small, I get the 
following error that shows up at my R prompt:

Error: Cannot pop the top-level viewport (grid and graphics output mixed?)

The error seems harmless, but eventually, after doing this "enough", and 
closing the graphics window, R may segfault,

  *** caught segfault ***
address 0xfc, cause 'memory not mapped'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

I have tracked down the error message I am receiving with some very 
rudimentary techniques, and narrowed it down to the L_unsetviewport 
function defined in grid.c.  The error string in question appears two 
places in that function, and I determined in my case that it is the 
first instance that is actually outputting the error.  That's about as 
far as I can take it unfortunately.

Again, this only seems to happen after I load the tcltk package.

I am running RHEL version 4 with KDE on a 32-bit Intel processor.

Here is my session info, immediately after starting R...

sessionInfo()
R version 2.7.0 (2008-04-22)
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=C;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] stats     graphics  grDevices utils     datasets  methods   base


Thanks,
Erik Iverson



[Rd] grid error message when resizing graphics window after tcltk loaded
Erik Iverson