| Ticket UUID: | 1381436 | ||
| Title: | threaded tcl crashes | ||
| Type: | Bug | Created on: | 2005-12-15 10:07:20 |
| Submitter: | yahalom | Assigned to: | andreas_kupries |
| Subsystem: | 49. Threading | Severity: | |
| Priority: | 9 Immediate | Last modified: | 2009-06-18 15:23:45 |
| Status: | Closed | Closed by: | andreas_kupries |
| Resolution: | Fixed | Closed on: | 2006-03-14 20:38:01 |
| Version: | obsolete: 8.4.12 | ||
| Description: | ||||
tcl:8.4.2.12 thread: 2.6.2 windows: server 2003 when using tcl many threads tcl crashes. 0000: 41 70 70 6c 69 63 61 74 Applicat 0008: 69 6f 6e 20 46 61 69 6c ion Fail 0010: 75 72 65 20 20 74 63 6c ure tcl 0018: 73 68 38 34 74 2e 65 78 sh84t.ex 0020: 65 20 38 2e 34 2e 32 2e e 8.4.2. 0028: 31 32 20 69 6e 20 74 63 12 in tc 0030: 6c 38 34 74 2e 64 6c 6c l84t.dll 0038: 20 38 2e 34 2e 32 2e 31 8.4.2.1 0040: 32 20 61 74 20 6f 66 66 2 at off 0048: 73 65 74 20 30 30 30 36 set 0006 0050: 62 33 64 63 b3dc this looks like the same phenomena I reported in the past on bug number 859820 submitted on 2003-12-14 04:54. locking the open/close pipe with tsv::lock stops the crash a thing which supports my assumption. doesn't the patch that was created in the previous bug report inserted to the version? I tried to apply the bug suggested on that bug but I still get the error. can a new patch be created? | ||||
| User Comments: | ||||
yahalom added on 2005-12-15 17:39:43:
Logged In: YES
user_id=130120
compiling with symbos this is what I get:
unsigned long
TclpGetPid(
Tcl_Pid pid)/* The HANDLE of the child
process. */
{
ProcInfo *infoPtr;
Tcl_MutexLock(&pipeMutex);
for (infoPtr = procList; infoPtr != NULL; infoPtr =
infoPtr->nextPtr) {
if (infoPtr->hProcess == (HANDLE) pid) {
Tcl_MutexUnlock(&pipeMutex);
==> return infoPtr->dwProcessId;
}
}
Tcl_MutexUnlock(&pipeMutex);
return (unsigned long) -1;
}
the exception is on :return infoPtr->dwProcessId;
vasiljevic added on 2005-12-20 19:23:34:
Logged In: YES
user_id=95086
Hm.... this is bad. The mutex is released too early, referencing the
infoPtr->dwProcessId w/o protection. I do not know if this is the
cause of the problem (have to examine that code more carefully)
but on the first glance I'd do:
if (infoPtr->hProcess == (HANDLE) pid) {
unsigned long processId = infoPtr->dwProcessId;
Tcl_MutexUnlock(&pipeMutex);
return processId;
}
If you do this in your copy, can you still reproduce the bug?
yahalom added on 2005-12-20 21:40:50:
Logged In: YES
user_id=130120
I still get an exception but this time in a different place.
TclpGetPid(
Tcl_Pid pid)/* The HANDLE of the child
process. */
{
ProcInfo *infoPtr;
Tcl_MutexLock(&pipeMutex);
for (infoPtr = procList; infoPtr != NULL; infoPtr =
infoPtr->nextPtr) {
==>if (infoPtr->hProcess == (HANDLE) pid) {
unsigned long processId = infoPtr-
>dwProcessId;
Tcl_MutexUnlock(&pipeMutex);
return processId;
}
}
Tcl_MutexUnlock(&pipeMutex);
return (unsigned long) -1;
}
vasiljevic added on 2005-12-20 21:45:02:
Logged In: YES user_id=95086 Well, then it is pretty clear. The global "procList" is busted. This is more difficult to trace as I'm not very familiar with the Windows sources. I will give it a try though. yahalom added on 2006-01-11 14:53:53:
Logged In: YES user_id=130120 I compiled tcl with mingw and the crash does not happen. it seems that compiling threaded tcl with vc 6 does not work well on windows 2003. vasiljevic added on 2006-01-11 21:52:08:
Logged In: YES user_id=95086 Great. What a mess... Did you try compiling with VC6 but turning OFF compiler optimizations? vasiljevic added on 2006-01-15 02:28:58:
Logged In: YES user_id=95086 I do not know if this applies here but I have commited a fix to core-8-4-branch which closes a potential hole in TclVFS which MAY (not sure) be relevant to the described problem. Can you please checkout and try? yahalom added on 2006-01-15 13:47:17:
Logged In: YES user_id=130120 I have a bit of work pressure so it will take some time. what file should I checkout? vasiljevic added on 2006-01-15 16:30:01:
Logged In: YES user_id=95086 Hey, no rush! The file is: generic/tclIOUtil.c for core-8-4-branch yahalom added on 2006-01-24 15:33:31:
Logged In: YES user_id=130120 I rechecked and the crash is happening with mingw. I tried the patch you suggested but it still crashed)-: I took the patch from bug 859820 I reported in the past and applied it to the 8.4.12 source and it seems to solve the problem. I do not know how tcl cvs is managed but this seems strange!!! I attach the patch from bug 859820 and the fixed file I made vasiljevic added on 2006-01-24 15:48:03:
Logged In: YES user_id=95086 Well, the cvs is managed pretty simple. Any developer who verifies and fixes the bug is free to apply it to the codebase unless the fix has some unwanted side effects. As a good netiquette, the one is expected to discuss this fix with the corresponding Tcl core-maintainer assiged to this subsystem and/or at the Tcl core maillist. This is now I usually work. In this case, the bug was obviously addressed but not applied to the codebase. I will reassign this open bug to David as I believe he's the one who made the patch you tried. If this fixes your problem, as it apparently does, I see no problem for David to apply the patch to both 8.4 and 8.5 core. David, can you please make sure this gets into the cvs? hobbs added on 2006-02-16 07:23:35:
Logged In: YES user_id=72656 Can I get a confirmation of what needs to be applied for 8.4.13, if anything? dgp added on 2006-03-10 10:08:04:
Logged In: YES user_id=80530 someone knowledgable please weigh in about what, if anything, needs doing before 8.4.13. davygrvy added on 2006-03-10 14:52:45:
Logged In: YES user_id=7549 I really don't have my "fu" these days when it comes to coding. I'm just a bit out-of-practice. I'd go with my conclutions from 859820 and apply the diff from r1.39->r1.40 of tclWinPipe.c to the 8.4 branch. andreas_kupries added on 2006-03-15 03:38:01:
Logged In: YES user_id=75003 I have applied this diff to the 8.4 head now. Extended the comments a bit to explain the problem behind the fix. dkf added on 2009-06-18 15:23:45:
allow_comments - 1 | ||||
