[Rd] 'tcltk' crashes related to event-loops (PR#14187)

From: <landronimirc_at_gmail.com>
Date: Sat, 16 Jan 2010 14:35:11 +0100 (CET)

Content-Type: text/plain; charset=UTF-8

I am experiencing some regular crashes on Debian Linux, 32- and 64-bit, involving 'tcltk' and 'cairoDevice' or 'RGtk2'. They make it very difficult to use tcltk interfaces (Rcmdr) and GTK+ ones (rattle, playwith, etc.) in the same R session.

NOTE: Before you continue, please read NOTE2 located towards the end of the message.

To reproduce you need to load 'tcltk' and 'cairoDevice' in the same R --vanilla session. When executing the following in that order, in a new terminal window:
ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world!",icon="info",type="ok") ### click "ok"

I get a crash (confirmed by Dirk---copied---on his Debian system) with the following message (see R-tcltk-cairoDevice.txt):
> The program 'R' received an X Window System error.
This probably reflects a bug in the program. The error was 'BadWindow (invalid Window parameter)'.  (Details: serial 317 error_code 3 request_code 15 minor_code 0)  (Note to programmers: normally, X errors are reported asynchronously;   that is, you will receive the error a while after causing it.   To debug your program, run it with the --sync command line   option to change this behavior. You can then get a meaningful   backtrace from your debugger if you break on the gdk_x_error() function.)

The crash and error are very similar in case of 'RGtk2': require(tcltk)
ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world!",icon="info",type="ok") ### click "ok" to get the crash

There are other ways to obtain the same error messages, but without concurrent crashes.
liviu_at_debian-liv:~$ R --vanilla
fix(iris) ### click "quit"
ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world!",icon="info",type="ok") ### click "ok"
ReturnVal <- tkmessageBox(title="Greetings from R TclTk",message="Hello, world!",icon="info",type="ok") ### click "ok"; to get the warnings(), this needs done twice

Then I get:
"There were 16 warnings (use warnings() to see them)"
> warnings()

Warning messages:
1: In structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), ... :  X11 protocol error: BadWindow (invalid Window parameter) [.. and 16 other same messages ..]

Yet another way is via Rcmdr, with a slightly different message: liviu_at_debian-liv:~$ R --vanilla

### select "iris" as active dataset
### click "edit" button, then "quit" the editor
### click "view" button, then close the viewer
### close Rcmdr and about 16 such errors will pop up

Warning in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), class = "tclObj") :
 X11 protocol error: BadWindow (invalid Window parameter)

Inverting the order of the calls, say,

sporadically generates tcltk freezes, with a different error message. I will submit a separate bug report on this.

NOTE1 I've already contacted in private several R developers (all copied), and below are some comments.
On Fri, Jan 8, 2010 at 2:41 PM, Michael Lawrence <lawrence.michael_at_gene.com> wrote:
> From the looks of it, the problem is on the tcltk side. When you load RGtk2,
> cairoDevice, or probably any package that links to GTK+ (well technically
> Gdk), the X11 error is handled differently. Yes, the error occurs (is
> reported?) sooner, which I can't explain, but again there's obviously
> something going wrong in tcltk.

On 1/11/10, Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk> wrote:
> The warnings have been puzzling me for quite a while in "pure" tcltk
> applications. They don't usually cause a crash, though, and the --sync
> bit in the message suggests that this comes from error handling outside
> of the tcltk package (R doesn't have a --sync option).


> Clearly, this sort of error comes from deleting windows with pending
> messages or sending messages to deleted windows, but I never got a
> handle on how to debug it. At the root of it is of course the
> unconventional way in which the event loop is hacked into the keyboard loop.

NOTE2 It seems that I found a circumstance that might help to explain/track down the underlying issue. Test case 1:

- make sure no R session is running
- open an R --vanilla session
- open a second R --vanilla session in a different terminal/tab
- run any of the crash-generating code (see above)
- you might *not* get the crash

Test case 2:

- make sure no R session is running
- open an R --vanilla session
- require(tcltk)
- open a second R --vanilla session in a different terminal/tab
- run any of the crash-generating code (see above)
- you should get a crash

It seems that the "tcltk with GTK" crashes occur when another R instance has tcltk loaded.

liviu_at_debian-liv:~$ uname -a
Linux debian-liv 2.6.30-2-amd64 #1 SMP Mon Dec 7 05:21:45 UTC 2009 x86_64 GNU/Linux
liviu_at_debian-liv:~$ cat /etc/apt/sources.list | grep cran2deb deb http://debian.cran.r-project.org/cran2deb/debian-amd64/ testing/

> sessionInfo()

R version 2.10.1 (2009-12-14)


 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C

attached base packages:
[1] tcltk stats graphics grDevices utils datasets methods [8] base

other attached packages:
[1] cairoDevice_2.10

> version

platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
major          2
minor          10.1
year           2009
month          12
day            14
svn rev        50720
language       R

version.string R version 2.10.1 (2009-12-14)


Content-Type: text/plain; charset=US-ASCII; name="R-tcltk-cairoDevice.txt"
Content-Disposition: attachment; filename="R-tcltk-cairoDevice.txt"
Content-Transfer-Encoding: base64

X-Attachment-Id: f_g4icq5rx1

bGl2aXVAZGViaWFuLWxpdjp+JCBSIC0tdmFuaWxsYQoKUiB2ZXJzaW9uIDIuMTAuMSAoMjAwOS0x Mi0xNCkKQ29weXJpZ2h0IChDKSAyMDA5IFRoZSBSIEZvdW5kYXRpb24gZm9yIFN0YXRpc3RpY2Fs IENvbXB1dGluZwpJU0JOIDMtOTAwMDUxLTA3LTAKClIgaXMgZnJlZSBzb2Z0d2FyZSBhbmQgY29t ZXMgd2l0aCBBQlNPTFVURUxZIE5PIFdBUlJBTlRZLgpZb3UgYXJlIHdlbGNvbWUgdG8gcmVkaXN0 cmlidXRlIGl0IHVuZGVyIGNlcnRhaW4gY29uZGl0aW9ucy4KVHlwZSAnbGljZW5zZSgpJyBvciAn bGljZW5jZSgpJyBmb3IgZGlzdHJpYnV0aW9uIGRldGFpbHMuCgogIE5hdHVyYWwgbGFuZ3VhZ2Ug c3VwcG9ydCBidXQgcnVubmluZyBpbiBhbiBFbmdsaXNoIGxvY2FsZQoKUiBpcyBhIGNvbGxhYm9y YXRpdmUgcHJvamVjdCB3aXRoIG1hbnkgY29udHJpYnV0b3JzLgpUeXBlICdjb250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cgZXJyb3JfY29k ZSAzIHJlcXVlc3RfY29kZSAxNSBtaW5vcl9jb2RlIDApCiAgKE5vdGUgdG8gcHJvZ3JhbW1lcnM6 IG5vcm1hbGx5LCBYIGVycm9ycyBhcmUgcmVwb3J0ZWQgYXN5bmNocm9ub3VzbHk7CiAgIHRoYXQg aXMsIHlvdSB3aWxsIHJlY2VpdmUgdGhlIGVycm9yIGEgd2hpbGUgYWZ0ZXIgY2F1c2luZyBpdC4K ICAgVG8gZGVidWcgeW91ciBwcm9ncmFtLCBydW4gaXQgd2l0aCB0aGUgLS1zeW5jIGNvbW1hbmQg bGluZQogICBvcHRpb24gdG8gY2hhbmdlIHRoaXMgYmVoYXZpb3IuIFlvdSBjYW4gdGhlbiBnZXQg YSBtZWFuaW5nZnVsCiAgIGJhY2t0cmFjZSBmcm9tIHlvdXIgZGVidWdnZXIgaWYgeW91IGJyZWFr IG9uIHRoZSBnZGtfeF9lcnJvcigpIGZ1bmN0aW9uLikK --0016e6d464cff5d753047d482362--

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 16 Jan 2010 - 13:38:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Jan 2010 - 05:00:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive