Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-05-27
10:22 • Closed ticket [406058ffff]: Bug in thread library plus 2 other changes artifact: e4a51244f3 user: davygrvy
2001-05-12
06:28 • Ticket [406058ffff]: 4 changes artifact: 6b17397e2b user: davygrvy
06:24 • Open ticket [406058ffff]. artifact: 5a3ed94bb9 user: davygrvy
05:40 • Ticket [406058ffff]: 6 changes artifact: c7e1bfc03f user: davygrvy
2001-05-11
21:22 • Ticket [406058ffff]: 6 changes artifact: c9fa811f46 user: villalba
05:22 • Ticket [406058ffff]: 6 changes artifact: a92bdf6d97 user: davygrvy
05:18 • Ticket [406058ffff]: 4 changes artifact: 061efb93e2 user: nobody
05:18 • Add attachment test1.c to ticket [406058ffff] artifact: ba6121aeff user: nobody
02:11 • Ticket [406058ffff] Bug in thread library status still Closed with 4 other c... artifact: 8bc3c887f1 user: davygrvy
2001-05-10
20:50 • Ticket [406058ffff]: 6 changes artifact: 6abbe2a6d1 user: villalba
2001-04-28
10:01 • Closed ticket [406058ffff]. artifact: f6b74d7e89 user: davygrvy
2001-04-26
05:24 • Ticket [406058ffff]: 1 change artifact: f3c8e3a2a5 user: dgp
05:03 • Ticket [406058ffff]: 5 changes artifact: 209e868f31 user: dgp
04:36 • Ticket [406058ffff]: 4 changes artifact: 6915fc5b70 user: davygrvy
2001-03-06
17:24 • Ticket [406058ffff]: 1 change artifact: db16eed9cf user: dkf
2001-03-05
17:21 • New ticket [406058ffff]. artifact: f58c09d0f6 user: villalba

Bug in thread library

Closed / Duplicate406058ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2001-03-05 17:21:49
working with Thread-2.1 under Windows-NT I found the  
following bug. While executing

    for {set i 0} {$i < 1000} {incr i} { 
set T [thread::create] 
catch "thread::send $T thread::exit"
    }

you can see in Task manager (of windows) that the  
number of handles* grows up.

* under processes in task manager choose columns in  
View menu and mark number of handles.

Greetings,
Villalba
dkf Ticket [406058ffff]: 1 change [History diff]2001-03-06 17:24:36
davygrvyplain2001-04-26 04:36:58
Logged In: YES 
user_id=7549

change the catagory to the thread package, please.

see https://sourceforge.net/tracker/index.php?
func=detail&aid=418689&group_id=10894&atid=110894

for a possible solution.
dgpplain2001-04-26 05:03:08
Logged In: YES 
user_id=80530

Changed category as requested.
dgp Ticket [406058ffff]: 1 change [History diff]2001-04-26 05:24:01
davygrvyplain2001-04-28 10:01:38
Logged In: YES 
user_id=7549

See https://sourceforge.net/tracker/index.php?
func=detail&aid=419683&group_id=10894&atid=110894 for the 
proposed fix.
villalbaplain2001-05-10 20:50:11
Logged In: YES 
user_id=166340

It isn´t a problem of the thread library, but Tcl core. Pay 
attention to the following easy example.

#include <tcl.h>

int ThreadMainProc( int& I ) 
{
I = 0;
return 0;
}

int main( void )
{
int I = 1;
Tcl_ThreadId* ThreadId = NULL;

// At this point the number of handles is 14 and of 
threads 1.

if( Tcl_CreateThread(
ThreadId, 
(unsigned int (__stdcall *)(void 
*)) ThreadMainProc,
&I,
TCL_THREAD_STACK_DEFAULT,
TCL_THREAD_NOFLAGS ) != TCL_OK)
{
return 1;// Error handle
}

// This loop is finished by the thread.
// At this point the number of handles is 15 and of 
threads 2.
while( I )
printf( "%d", I );

// At this point the number of handles is 15 and of 
threads 1, i.e. the thread is dead.

return 0;
}
davygrvyplain2001-05-11 02:11:31
Logged In: YES 
user_id=7549

See http://sourceforge.net/tracker/?
func=detail&atid=110894&aid=419683&group_id=10894

for the patch that fixes your problem as was stated before.
nobodyplain2001-05-11 05:18:42
File Added - 6187: test1.c
davygrvyplain2001-05-11 05:22:05
Logged In: YES 
user_id=7549

Under deeper inspection of your code, I'd like to edit it 
for better cross-platform support of the threading macros 
in tcl.h.  Honestly, casting of function types is evil.  
Especially the calling convention part.  I don't think I'm 
being nit-picky because the compiler will emit different 
different machine code for __cdecl and __stdcall.  Try it 
and look at the difference of the stack handling of the 
listing .asm file.  There's no handle leak present with the 
patch from 419683 applied.
villalbaplain2001-05-11 21:22:04
Logged In: YES 
user_id=166340

I´ve tried the patch http://sourceforge.net/tracker/?
func=detail&atid=110894&aid=419683&group_id=10894 but it 
isn´t successful.
davygrvyplain2001-05-12 05:40:54
Logged In: YES 
user_id=7549

All I can say is that it worked for me and dropping the 
handle reference in Tcl_CreateThread did cause the app's 
handle count to decrement when the thread closed.

If you have any other ideas for a fix, let me know.
davygrvy Open ticket [406058ffff]. [History diff]2001-05-12 06:24:44
davygrvyplain2001-05-12 06:28:51
Logged In: YES 
user_id=7549

I should have said, "never caused the app's handle count to 
increment at all."
davygrvy Closed ticket [406058ffff]. [History diff]2001-05-27 10:22:40
Log in (anonymous is fine) to add a comment.

Attachments: