crash in SocketThreadExitHandler
Closed / Fixed650353ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 22 years ago
Descriptionplain2002-12-08 06:58:10
This is a bug that started appearing very recently. During Tcl_Finalize, the socket exit handler is trying to fetch data from a thread local storage index (line 562). The actual fetch succeeds. However, the return value is NULL, the SocketThreadExitHandler immediately tries to dereference this pointer (line 564) without checking for NULL. Checking these pointers for NULL would be nice... However, I believe this is just a symptom of a bigger problem which needs to be uncovered. Based on the diagnostic messages I added to the thread local storage functions, I believe that the data for this particular thread local storage index is NEVER set to a non-NULL value. SocketThreadExitHandler(void * 0x00000000) line 562 + 10 bytes SocketExitHandler(void * 0x00000000) line 528 + 9 bytes Tcl_Finalize() line 840 + 12 bytes I'm wondering if this code has been recently changed. -- JJM
nobodyplain2002-12-08 14:10:39
Logged In: NO A search for "SocketThreadExitHandler(clientData);" in the various CVS revisions reveals that this is/was broken as of CVS revision 1.28 (Wed Nov 27 00:58:01 2002 UTC (11 days, 6 hours ago)). JJM
hobbs Ticket [650353ffff]: 2 changes
[History diff]2002-12-08 14:45:42
andreas_kupries Ticket [650353ffff]: 1 change
[History diff]2002-12-08 14:50:05
nobodyplain2002-12-08 15:27:43
Logged In: NO
I have a potential fix for this bug (file win/tclWinSock.c).
static void
SocketExitHandler(clientData)
ClientData clientData; /* Not used. */
{
ThreadSpecificData *tsdPtr =
(ThreadSpecificData *)TclThreadDataKeyGet
(&dataKey); /* NEW: checked below */
Tcl_MutexLock(&socketMutex);
if (winSock.hModule) {
/*
* Make sure the socket event handling
window is cleaned-up
* for, at most, this thread.
*/
if (tsdPtr != NULL) /* ONLY call thread exit handler
when the thread has been previously initialized by
InitSockets */
SocketThreadExitHandler(clientData);
davygrvyplain2002-12-08 22:39:30
Logged In: YES user_id=7549 Fixed, thanks for the report.
nobodyplain2004-06-16 18:32:38
Logged In: NO In SocketThreadExitHandler ----- WaitForSingleObject(tsdPtr->socketThread, INFINITE); it will cause SocketThreadExitHandler hang..forever. if change timeout into some number, could clean the garbage by OS?
Log in (anonymous is fine) to add a comment.