Tk Source Code

View Ticket
Login
Ticket UUID: bcbf4c9875971fae8e4dbf2b93497459b4dbf1bc
Title: Tk intialization overwrites thread specific data
Type: Bug Version: trunk
Submitter: emiliano Created on: 2024-11-25 02:13:35
Subsystem: 69. Events Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2024-11-25 21:12:10
Resolution: Fixed Closed By: fvogel
    Closed on: 2024-11-25 21:12:10
Description:
The function tkEventInit in generic/tkEvent.c

https://core.tcl-lang.org/tk/file?name=generic/tkEvent.c&ln=1010

unconditionally initialize all the fields of (ThreadSpecificData *)tsdPtr to 0 or NULL.

This is wrong since the function is called for each new interpreter in which Tk is loaded, effectively deleting all the information tsdPtr carries out for a given thread, resulting in memory leaks and other problems like wiping out callbacks registered by Tk_CreateGenericHandler(), etc.

This function should not be needed since the documentation for Tcl_GetThreadData reads "The storage is automatically allocated and initialized to all zeros the first time each thread asks for it."
User Comments: fvogel added on 2024-11-25 21:12:10:

Fixed by Jan today, see [df1a487a] and upward merges.