Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-06-18
15:23 • Ticket [1381436fff] threaded tcl crashes status still Closed with 4 other ch... artifact: 44a9b8477a user: dkf
2006-03-15
03:38 • Closed ticket [1381436fff]. artifact: aeaf84c925 user: andreas_kupries
2006-03-10
22:05 • Ticket [1381436fff]: 1 change artifact: ad6be080f5 user: dgp
14:52 • Ticket [1381436fff]: 4 changes artifact: d4077dce6f user: davygrvy
10:08 • Ticket [1381436fff]: 4 changes artifact: 63b8d85fbb user: dgp
2006-02-16
07:23 • Ticket [1381436fff]: 5 changes artifact: 7e3ea93904 user: hobbs
2006-01-24
15:48 • Ticket [1381436fff]: 5 changes artifact: e4f6f1b4b5 user: vasiljevic
15:33 • Ticket [1381436fff]: 4 changes artifact: b4f79669a8 user: yahalom
2006-01-15
16:30 • Ticket [1381436fff]: 4 changes artifact: e1aa082ef4 user: vasiljevic
13:47 • Ticket [1381436fff]: 4 changes artifact: 180648fc1a user: yahalom
02:28 • Ticket [1381436fff]: 4 changes artifact: 252417ffb6 user: vasiljevic
2006-01-11
21:52 • Ticket [1381436fff]: 4 changes artifact: 208d8703dd user: vasiljevic
14:53 • Ticket [1381436fff]: 4 changes artifact: bb205f8ce8 user: yahalom
2005-12-20
21:45 • Ticket [1381436fff]: 4 changes artifact: bba66834b7 user: vasiljevic
21:40 • Ticket [1381436fff]: 4 changes artifact: 08c4a21a3c user: yahalom
19:23 • Ticket [1381436fff]: 4 changes artifact: da1873fdb1 user: vasiljevic
2005-12-15
20:26 • Ticket [1381436fff]: 2 changes artifact: 2fc4c22972 user: dkf
17:39 • Ticket [1381436fff]: 4 changes artifact: 6aa416f306 user: yahalom
10:07 • New ticket [1381436fff]. artifact: 6e1c89f9e5 user: yahalom

threaded tcl crashes

Closed / Fixed1381436fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 17 years ago
Descriptionplain2005-12-15 10:07:20
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?
yahalomplain2005-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;
dkf Ticket [1381436fff]: 2 changes [History diff]2005-12-15 20:26:06
vasiljevicplain2005-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?
yahalomplain2005-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;
}
vasiljevicplain2005-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.
yahalomplain2006-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.
vasiljevicplain2006-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?
vasiljevicplain2006-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?
yahalomplain2006-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?
vasiljevicplain2006-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
yahalomplain2006-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
vasiljevicplain2006-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?
hobbsplain2006-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?
dgpplain2006-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.
davygrvyplain2006-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.
dgp Ticket [1381436fff]: 1 change [History diff]2006-03-10 22:05:12
andreas_kupriesplain2006-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.
dkfplain2009-06-18 15:23:45
allow_comments - 1
Log in (anonymous is fine) to add a comment.