| Ticket UUID: | 731754 | ||
| Title: | tls index leak/inconsistencies in tclThreadAlloc.c, etc | ||
| Type: | Bug | Created on: | 2003-05-03 09:00:35 |
| Submitter: | nobody | Assigned to: | mistachkin |
| Subsystem: | 49. Threading | Severity: | |
| Priority: | 9 Immediate | Last modified: | 2003-05-10 06:38:02 |
| Status: | Closed | Closed by: | mistachkin |
| Resolution: | Fixed | Closed on: | 2003-05-09 23:38:02 |
| Version: | None | ||
| Description: | ||||
In the CVS HEAD version of tclThreadAlloc.c, near
line #279, the following lines of code can be found:
#ifdef WIN32
TlsFree((DWORD) cachePtr);
#else
free(cachePtr);
#endif
After seeing this code and, I investigated it more
carefully to see if I could more precisely figure out
it's implications. Here are my preliminary
conclusions:
#1. It turns out that calling TlsFree on cachePtr is
NOT correct.
#2. Calling free() on it produces a very strange
crash in PutBlocks (null pointer dereference on line
826).
#3. In an attempt to fix this problem, I moved the
call to TlsFree to tclWinThrd.c, where it really
belongs anyhow. However, calling TlsFree on
the "key" static variable in this file, which is what
cachePtr is based on, does not produce good
results.
I am not sure how to fix this problem because I
believe it may point to deeper issues with the
threaded memory allocator. Any help on this issue,
and more generally, my non-TLS patch, would be
greatly appreciated.
If indeed TlsFree (or it's new non-TLS equivalent)
must be called from tclThreadAlloc.c, it would
make my patch a lot cleaner if TclFreeAllocCache
called into a wrapper function residing in
tclWinThrd.c, where I can use my new non-TLS
thread storage subsystem if necessary.
JJM
| ||||
| User Comments: | ||||
mistachkin added on 2003-05-03 18:17:53:
Logged In: YES user_id=113501 Apparently, the TLS index for the threaded memory allocator is never freed. Therefore, it is being leaked upon load/unload/reload of the Tcl DLL. msofer added on 2003-05-04 00:02:02:
Logged In: YES user_id=148712 Back to Joe: I have no relevant knowledge on these matters :( mistachkin added on 2003-05-05 13:13:41:
Logged In: YES user_id=113501 It appears, based on CVS history, that this is JeffH's area. Assigning to him. mistachkin added on 2003-05-05 13:15:26:
Logged In: YES user_id=113501 This bug is fixed in my Win32 NON-Tls thread storage patch. patch #731356 mistachkin added on 2003-05-10 06:38:02:
Logged In: YES user_id=113501 Memory leak fixed. all platforms now call: free(cachePtr); The more general problem of when to free the TLS index for the threaded memory allocator has been solved by my Win32 non-TLS patch. However, I'm in the middle of reworking it to make it more modular before it's committed. | ||||
