Tk Source Code

View Ticket
Login
Ticket UUID: 1283635
Title: Crash manipulating transient windows on MSWin
Type: Bug Version: obsolete: 8.4.11
Submitter: djarseneau Created on: 2005-09-07 07:27:37
Subsystem: 68. Win Window Operations Assigned To: chengyemao
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2005-12-01 05:58:40
Resolution: Fixed Closed By: hobbs
    Closed on: 2005-11-30 22:58:40
Description:
The attached file causes a crash when the three
transient (dwarf) windows are closed,  using ActiveTcl
 8.4.11.1 on Windows XP, but not  8.4.7 on Linux, and
not 8.3 on either.

The file is work in progress from a year ago, managing
multiple transient dialogs.  It isn't a final product,
and performs much worse with 8.4 than 8,3, but that is
beside the point for the crash.
User Comments: hobbs added on 2005-12-01 05:58:40:
Logged In: YES 
user_id=72656

It may be harmless or unnecessary in 8.4, but it can't hurt,
so I backported it for 8.4.12.

dgp added on 2005-12-01 01:06:46:
Logged In: YES 
user_id=80530


backport status?  Is this
or will this be in the 8.4.12
release?

nobody added on 2005-09-13 07:23:58:
Logged In: NO 

After the first check-in, I found it may not be proper for the 
purpose of cleaning-up wrapper,  so I changed the code back 
and put an if-statement to stop calling TkInstallFrameMenu in 
UpdateWrapper in case the window is already dead (around 
line 2141).

       if( !(winPtr->flags & TK_ALREADY_DEAD) ) 
         TkInstallFrameMenu((Tk_Window) winPtr);

I tested the code for both Tk84 and Tk85 and it worked fine. 
But I did not checked in the modificaiton for Tk84.

Chengye

hobbs added on 2005-09-13 06:32:46:
Logged In: YES 
user_id=72656

I see that this was applied to 8.5 and not 8.4.  I would
like to backport it, but there appears to be some
conflicting code.  The 2nd change made in the 8.5 diff is
equal to the 8.4 code already.  I am not able to replicate
this on 8.4 though.  Is just the first diff necessary?

The 8.5 diff was:

@@ -2141,7 +2141,8 @@
        wmPtr->x = place.rcNormalPosition.left;
        wmPtr->y = place.rcNormalPosition.top;

-       TkInstallFrameMenu((Tk_Window) winPtr);
+       if( !(winPtr->flags & TK_ALREADY_DEAD) )
+           TkInstallFrameMenu((Tk_Window) winPtr);

        if (oldWrapper && (oldWrapper != wmPtr->wrapper)
                && !(wmPtr->exStyle & WS_EX_TOPMOST)) {
@@ -2281,7 +2282,7 @@
     if (childStateInfo) {
        if (wmPtr->numTransients > 0) {
            /*
-            * Reset all alive transient children for whom
this is the master
+            * Reset all transient children for whom this is
the master
             */
            WmInfo *wmPtr2;

@@ -2289,8 +2290,7 @@
            for (wmPtr2 = winPtr->dispPtr->firstWmPtr;
wmPtr2 != NULL;
                 wmPtr2 = wmPtr2->nextPtr) {
                if (wmPtr2->masterPtr == winPtr) {
-                   if (  !(wmPtr2->flags & WM_NEVER_MAPPED)
-                       && (wmPtr2->winPtr->flags &
TK_ALREADY_DEAD)) {
+                   if ( !(wmPtr2->flags & WM_NEVER_MAPPED)) {
                        UpdateWrapper(wmPtr2->winPtr);
                        TkpWmSetState(wmPtr2->winPtr,
childStateInfo[state++]);
                    }

chengyemao added on 2005-09-11 08:07:22:
Logged In: YES 
user_id=191079

This bug is caused by UpdateWrapper of TkWinWm.c to 
reset all transient children without first checking if the child is 
already dead.  It is not only a bug of Tcl84.11 but also other 
versions including 85.  

I have fixed this bug in the current Tk85 and checked in the 
code. 

Chengye Mao

chengyemao added on 2005-09-08 12:38:12:
Logged In: YES 
user_id=191079

Duplicated the crash in my XP when closing the third dialog 
box.  The following was the stack when crashing occured:

TkInstallFrameMenu(Tk_Window_ * 0x05d6ab70) line 1845
UpdateWrapper(TkWindow * 0x05d6ab70) line 2115 + 9 bytes
TkWmDeadWindow(TkWindow * 0x05ea1850) line 2515 + 11 
bytes
Tk_DestroyWindow(Tk_Window_ * 0x05ea1850) line 1434 + 
9 bytes
Tk_DestroyObjCmd(void * 0x00a3a610, Tcl_Interp * 
0x00384b00, int 2, Tcl_Obj * const * 0x00385994) line 472 + 
9 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * 
const * 0x00385994, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05dd46e8) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd1320) line 982 + 13 bytes
TclObjInterpProc(void * 0x05eb8458, Tcl_Interp * 
0x00384b00, int 1, Tcl_Obj * const * 0x00385990) line 1100 
+ 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 1, Tcl_Obj * 
const * 0x00385990, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05ea31f8) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd15f0) line 982 + 13 bytes
TclObjInterpProc(void * 0x05eb5d30, Tcl_Interp * 
0x00384b00, int 2, Tcl_Obj * const * 0x00129354) line 1100 
+ 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * 
const * 0x00129354, const char * 0x001297b4, int 40, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x001297b4, int 40, int 0) line 3683 + 39 bytes
Tcl_Eval(Tcl_Interp * 0x00384b00, const char * 0x001297b4) 
line 3889 + 17 bytes
Tcl_GlobalEval(Tcl_Interp * 0x00384b00, const char * 
0x001297b4) line 5351 + 13 bytes
Tk_BindEvent(Tk_BindingTable_ * 0x00a5fda8, _XEvent * 
0x00129aa8, Tk_Window_ * 0x05d6ab70, int 0, void * * 
0x00129944) line 1806 + 25 bytes
TkBindEventProc(TkWindow * 0x05d6ab70, _XEvent * 
0x00129aa8) line 288 + 31 bytes
Tk_HandleEvent(_XEvent * 0x00129aa8) line 1057 + 13 bytes
Tk_DestroyWindow(Tk_Window_ * 0x05d6ab70) line 1402 + 
9 bytes
Tk_DestroyObjCmd(void * 0x00a3a610, Tcl_Interp * 
0x00384b00, int 2, Tcl_Obj * const * 0x00385988) line 472 + 
9 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * 
const * 0x00385988, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05d28b08) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd1638) line 982 + 13 bytes
TclObjInterpProc(void * 0x05dedbc0, Tcl_Interp * 
0x00384b00, int 5, Tcl_Obj * const * 0x0012a740) line 1100 
+ 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 5, Tcl_Obj * 
const * 0x0012a740, const char * 0x0012a990, int 60, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x0012a990, int 60, int 0) line 3683 + 39 bytes
TraceVarProc(void * 0x05da3b28, Tcl_Interp * 0x00384b00, 
const char * 0x05de9478, const char * 0x05ebf368, int 32) 
line 4736 + 25 bytes
CallVarTraces(Interp * 0x00384b00, Var * 0x05dedfc0, Var * 
0x05bd8f60, const char * 0x05de9478, const char * 
0x05ebf368, int 32, const int 512) line 4238 + 30 bytes
TclPtrSetVar(Tcl_Interp * 0x00384b00, Var * 0x05bd8f60, Var 
* 0x05dedfc0, const char * 0x05de9478, const char * 
0x05ebf368, Tcl_Obj * 0x05d65628, const int 512) line 1694 
+ 44 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05dbee20) line 1897 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05d32be0) line 982 + 13 bytes
Tcl_EvalObjEx(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05d32be0, int 131072) line 4022 + 13 bytes
TkInvokeButton(TkButton * 0x05d11d28) line 1548 + 35 bytes
ButtonWidgetObjCmd(void * 0x05d11d28, Tcl_Interp * 
0x00384b00, int 2, Tcl_Obj * const * 0x05eba698) line 888 + 
9 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * 
const * 0x05eba698, const char * 0x1014f604 `string', int 0, 
int 262144) line 3087 + 27 bytes
Tcl_EvalObjv(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * const 
* 0x05eba698, int 262144) line 3203 + 35 bytes
Tcl_EvalObjEx(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05d654d8, int 262144) line 4007 + 27 bytes
Tcl_UplevelObjCmd(void * 0x00000000, Tcl_Interp * 
0x00384b00, int 1, Tcl_Obj * const * 0x00385978) line 674 + 
20 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 3, Tcl_Obj * 
const * 0x00385970, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05d6eba0) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x00aaf8c0) line 982 + 13 bytes
TclObjInterpProc(void * 0x00acafb0, Tcl_Interp * 0x00384b00, 
int 2, Tcl_Obj * const * 0x0012c440) line 1100 + 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 2, Tcl_Obj * 
const * 0x0012c440, const char * 0x0012c8a5, int 36, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x0012c8a0, int 41, int 0) line 3683 + 39 bytes
Tcl_Eval(Tcl_Interp * 0x00384b00, const char * 0x0012c8a0) 
line 3889 + 17 bytes
Tcl_GlobalEval(Tcl_Interp * 0x00384b00, const char * 
0x0012c8a0) line 5351 + 13 bytes
Tk_BindEvent(Tk_BindingTable_ * 0x00a5fda8, _XEvent * 
0x05dc34f0, Tk_Window_ * 0x05da29e0, int 0, void * * 
0x0012ca34) line 1806 + 25 bytes
TkBindEventProc(TkWindow * 0x05da29e0, _XEvent * 
0x05dc34f0) line 288 + 31 bytes
Tk_HandleEvent(_XEvent * 0x05dc34f0) line 1057 + 13 bytes
WindowEventProc(Tcl_Event * 0x05dc34e8, int -3) line 1443 
+ 12 bytes
Tcl_ServiceEvent(int -3) line 637 + 13 bytes
Tcl_DoOneEvent(int -3) line 942 + 9 bytes
Tk_TkwaitObjCmd(void * 0x00a3a610, Tcl_Interp * 
0x00384b00, int 3, Tcl_Obj * const * 0x00385964) line 908 + 
16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 3, Tcl_Obj * 
const * 0x00385964, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05decbe0) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd1650) line 982 + 13 bytes
TclObjInterpProc(void * 0x05de4a78, Tcl_Interp * 
0x00384b00, int 5, Tcl_Obj * const * 0x0012d89c) line 1100 
+ 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 5, Tcl_Obj * 
const * 0x0012d89c, const char * 0x05e947d8, int 72, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x05e947d8, int 72, int 131072) line 3683 + 39 bytes
AfterProc(void * 0x05e96fc0) line 1039 + 22 bytes
TimerHandlerEventProc(Tcl_Event * 0x05d8e2a8, int -3) line 
543 + 15 bytes
Tcl_ServiceEvent(int -3) line 637 + 13 bytes
Tcl_DoOneEvent(int -3) line 942 + 9 bytes
Tk_TkwaitObjCmd(void * 0x00a3a610, Tcl_Interp * 
0x00384b00, int 3, Tcl_Obj * const * 0x00385958) line 908 + 
16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 3, Tcl_Obj * 
const * 0x00385958, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05decbe0) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd1650) line 982 + 13 bytes
TclObjInterpProc(void * 0x05de4a78, Tcl_Interp * 
0x00384b00, int 5, Tcl_Obj * const * 0x0012e878) line 1100 
+ 16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 5, Tcl_Obj * 
const * 0x0012e878, const char * 0x05e947d8, int 72, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x05e947d8, int 72, int 131072) line 3683 + 39 bytes
AfterProc(void * 0x05e96f10) line 1039 + 22 bytes
TimerHandlerEventProc(Tcl_Event * 0x05ead0f8, int -3) line 
543 + 15 bytes
Tcl_ServiceEvent(int -3) line 637 + 13 bytes
Tcl_DoOneEvent(int -3) line 942 + 9 bytes
Tk_TkwaitObjCmd(void * 0x00a3a610, Tcl_Interp * 
0x00384b00, int 3, Tcl_Obj * const * 0x0038594c) line 908 + 
16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 3, Tcl_Obj * 
const * 0x0038594c, const char * 0x00000000, int 0, int 0) 
line 3087 + 27 bytes
TclExecuteByteCode(Tcl_Interp * 0x00384b00, ByteCode * 
0x05decbe0) line 1418 + 33 bytes
TclCompEvalObj(Tcl_Interp * 0x00384b00, Tcl_Obj * 
0x05dd1650) line 982 + 13 bytes
TclObjInterpProc(void * 0x05de4a78, Tcl_Interp * 
0x00384b00, int 5, Tcl_Obj * const * 0x0012f854) line 1100 + 
16 bytes
TclEvalObjvInternal(Tcl_Interp * 0x00384b00, int 5, Tcl_Obj * 
const * 0x0012f854, const char * 0x05e947d8, int 72, int 0) 
line 3087 + 27 bytes
Tcl_EvalEx(Tcl_Interp * 0x00384b00, const char * 
0x05e947d8, int 72, int 131072) line 3683 + 39 bytes
AfterProc(void * 0x05e96e60) line 1039 + 22 bytes
TimerHandlerEventProc(Tcl_Event * 0x05e95f30, int -3) line 
543 + 15 bytes
Tcl_ServiceEvent(int -3) line 637 + 13 bytes
Tcl_DoOneEvent(int -3) line 942 + 9 bytes
Tk_MainLoop() line 1501 + 15 bytes
Tk_MainEx(int 1, char * * 0x0038269c, int (Tcl_Interp *)* 
0x00401005 _Tcl_AppInit, Tcl_Interp * 0x00384b00) line 293
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 
0x00000000, char * 0x00151f0e, int 1) line 130 + 37 bytes
WISH84! WinMainCRTStartup + 308 bytes
KER

In the last function,

TkInstallFrameMenu(tkwin)
    Tk_Window tkwin;/* The window that was just 
created. */
{
    TkWindow *winPtr = (TkWindow *) tkwin;

    if (winPtr->mainPtr != NULL) {
Frame *framePtr;
framePtr = (Frame*) winPtr->instanceData;
if (framePtr == NULL) {
    panic("TkInstallFrameMenu couldn't get frame 
pointer");
}
TkpMenuNotifyToplevelCreate(winPtr->mainPtr-
>interp, 
framePtr->menuName);
    }
}

framePtr (i.e., winPtr->instanceData) pointed to an invalid 
Frame structure and caused the crashing.  How the memory 
of instanceData became invalid is not clear.


Chengye Mao

hobbs added on 2005-09-08 00:51:44:
Logged In: YES 
user_id=72656

Can you better describe how to trigger this bug?  I cannot
get it to crash on XP SP2 using 8.4.11.1 (slightly later
than the release version).  I wait til all 3 dialogs are up,
then select a button on each to close - no problems.

djarseneau added on 2005-09-07 14:27:38:

File Added - 148290: tmb.tcl

Attachments: