Tk Source Code

View Ticket
Login
Ticket UUID: 1189899
Title: Crash on Windows during TkFinalize with threads
Type: Bug Version: obsolete: 8.4.11
Submitter: jfg118 Created on: 2005-04-25 23:59:25
Subsystem: 68. Win Window Operations Assigned To: mistachkin
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2006-03-29 12:52:58
Resolution: Fixed Closed By: hobbs
    Closed on: 2006-03-29 05:52:58
Description:
A crash occurs during the TkFinalize routine becase the 
main thread is exiting the application, and the Tk exit 
handler "assumes" that the exit handlers are valid for all 
threads.  The DeleteWindowsExitProc proc sends the 
thread specific data pointer as ClientData 
[tkWindow.c:363]. Inside of the DeleteWindowsExitProc 
function a call to Tcl_DestroyWindow 
[tkWindow.c:2729,2740] and TkCloseDisplay 
[tkWindow.c:1601] which calls TkpCloseDisplay 
[tkWindow.c:281] These windows specific functions 
LOOKUP the thread specific data instead of using the 
passed ClientData. Since a different thread is 
calling "TkFinalize" the lists become corrupted.
User Comments: hobbs added on 2006-03-29 12:52:58:
Logged In: YES 
user_id=72656

I have changed the 8.4.13 call to use
Tcl_CreateThreadExitHandler to correct this.

mistachkin added on 2006-03-11 03:24:22:
Logged In: YES 
user_id=113501

This may have already been fixed for 8.5 by 1247919.  I
believe the same change may need to be backported to 8.4.

dgp added on 2006-03-11 02:58:58:
Logged In: YES 
user_id=80530

still valid against 8.4.13 ?

hobbs added on 2005-12-01 14:38:39:
Logged In: YES 
user_id=72656

These patches actually caused my threaded 8.4 build to start
crashing on simple scripts.  The Tcl_GetThreadData may be
appropriate, but the use of thread exit handlers instead of
one final exit handler is causing issues that need further
analysis.

jfg118 added on 2005-10-22 07:11:42:

File Added - 153399: generic-tkWindow.c.diff-u

Logged In: YES 
user_id=1266631

Second file to patch attached.

jfg118 added on 2005-10-22 07:09:08:

File Added - 153398: win-tkWinMenu.c.diff-u

jfg118 added on 2005-10-22 07:08:45:
Logged In: YES 
user_id=1266631

The problem has been tracked to Tk code which registers exit
handlers but then uses thread specific data. The two files
patch these cases and setup threadexithandlers instead.  The
patch files fix the crash with Tk 8.4.11. It would be great
to get these rolled into Tk 8.4.12 as the problem was
introduced in Tk 8.4.8.

jfg118 added on 2005-04-26 06:59:34:

File Added - 131734: winTkFinalizeBug-t.c

Attachments: