[R] tcltk crashes with bad color with text widget

Duncan Murdoch murdoch at stats.uwo.ca
Wed Oct 18 04:40:19 CEST 2006


On 10/17/2006 8:36 AM, Peter Dalgaard wrote:
> Duncan Murdoch <murdoch at stats.uwo.ca> writes:
> 
>> On 10/16/2006 10:47 PM, Alex Couture-Beil wrote:
>>> Hello
>>>
>>> I have been playing with tcl/tk in R 2.4.0 on windows XP and have 
>>> managed to crash R by supplying tcl/tk with an incorrect color.
>>> Is this a bug? is there a way for me to test the color to see if it is a 
>>> valid tcl/tk color, to avoid this?
>>>
>>> tt=tktoplevel()
>>> tklabel(parent=tt, text="hello world", foreground="reed")
>>> Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), 
>>> class = "tclObj") :
>>>         [tcl] unknown color name "reed".
>>> An error is displayed as one would expect, however when I try
>>> tktext(parent=tt, foreground="blaaack")
>>> R crashes, rather than displaying an error as tklabel did.
>>>
>>> This, however, does not happen on my FreeBSD machine, which displays an 
>>> error similar to the one for tklabel and does not crash.
>> I see the same crash in Windows, occurring deep in one of the TCL 
>> routines, where it tries to work with a font, but the font has not been 
>> assigned.
>>
>> TK on Windows uses a different display driver than FreeBSD does, so this 
>> could be a TK bug, rather than an R bug, and it does look like that. 
>> Alternatively, we might be ignoring an error generated in TK, in which 
>> case it is our bug:  but the tklabel example makes that sound wrong.
>>
>> To verify, it would be nice to try the same commands in wish (or some 
>> other TCL/TK platform).  Do you know the pure TCL equivalent?
> 
> Should be close to this
> 
> toplevel .1
> label .1.1 -text "hello world" -foreground reed
> text .1.2 -foreground blaack
> 
> (and it doesn't crash on my machine, in R or wish)

I only see the crash in R, not in wish.  It happens when, in the midst 
of destroying the partially created text widget, TK needs to create the 
Windows window corresponding to it.  Windows sends some messages to the 
newly created window (including WM_NCCREATE), these lead to TK servicing 
idle events, and one of those involves looking the incomplete text 
object, and that's when things crash.

I don't know why wish can handle the error properly; maybe it just got 
lucky, or maybe it handles the error differently.

I think I'm going to have to give up on this one.

Duncan Murdoch



More information about the R-help mailing list