Tcl Source Code

View Ticket
Login
Ticket UUID: 3301634
Title: Thread release crash
Type: Bug Version: obsolete: 8.5.10
Submitter: tombert Created on: 2011-05-13 15:14:13
Subsystem: 80. Thread Package Assigned To: dgp
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2012-04-27 03:06:23
Resolution: Out of Date Closed By: dgp
    Closed on: 2012-04-26 20:06:23
Description:
Environment Windows7, TCL 8.5.9 release and HEAD, compiled with MinGW
User Comments: dgp added on 2012-04-27 03:06:23:

allow_comments - 1

tombert added on 2012-04-11 03:01:50:
Cant reproduce any more with latest head. Tested XP and W7.

dkf added on 2012-04-10 20:36:49:
Technically, since neither is actually particularly clearer as to the deep nature of the bug, we'd roll that one into this.

My main concern is that we have code that can crash at all. That's Bad.

sebres added on 2012-04-10 20:27:21:
possible duplicate to 3494470?
https://sourceforge.net/tracker/?func=detail&aid=3494470&group_id=10894&atid=110894

tombert added on 2012-04-10 16:00:16:
Retested in WinXP, TCL 8.5.11, thread 2.7b1: does not crash.
Have to try in W7.

tombert added on 2011-08-19 00:56:38:
ok - thx for the explanation, I'll take precaution not to release "myself" ...
... but this still leaves the crash open, I'll post a quick look into the code here:

package require Thread
proc crash {} {
    set ::tid [thread::create {thread::wait}]
    puts $::tid
    thread::send $::tid {
package require Itcl
namespace import itcl::*
source d:/crash/socket_crash.itcl
source d:/crash/util.tcl
set obj [socket_crash "#auto"]
    }
    thread::release $::tid
}
after idle crash

vasiljevic added on 2011-08-18 22:59:59:
Releasing the main thread is syntactically possible
and wrong. Actually releasing the 'current' thread
ie. one calling the thread::release should be disabled
or just a no-op'ed. I never thought of that as this is 
rarely practically done.

Releasing (i.e. letting it die away) any thread is always
connected with various cleanups that may go astray
in certain situations. For example, you lock a mutex in
a thread and then release the thread. Moreover, the 
Tcl lib was initially not desiged for thread safety. It is
added some years later. So the entire cleanup/finalize
machinery is not very thread-friendly and still assumes
a "main" thread (the one that started the program) is
always arround. 

So.,, you never exit a "main" thread (whichever that is)
and I will add a block that will effectively no-op the
release of the 'self' i.e current thread (as explained above).

Cheers
Zoran

andreas_kupries added on 2011-08-18 22:47:22:
Huh. Destruction of the main thread I would suspect to be a case of "pulling the rug out from under yourself".

tombert added on 2011-08-18 17:00:55:
Another interesting behaviour is calling (in a virgin wish):
> package re Thread
> thread::release [thread::id]

which does nothing in the first attempt, but calling it a second time it reports that the thread does not exists.
What is the expected result when releasing the main thread itself?

thx

tombert added on 2011-08-18 16:56:52:
Example still crashes in 8.5.10 and latest thread package release.
thx

tombert added on 2011-05-13 22:19:23:
Stripped down my application to reproduce the crash.
The configured default path in the files point to d:/crash/...

To reproduce call: wish crash.tcl
If one removes a single procedure from the util.tcl the crash won't happen no more. Or you can remove a few method declarations from the socket_crash class, this will lead to an allocation error.
Doing only "exit" without release works fine.

thx for support

tombert added on 2011-05-13 22:15:57:

File Added - 411524: util.tcl

tombert added on 2011-05-13 22:15:34:

File Added - 411523: socket_crash.itcl

tombert added on 2011-05-13 22:14:27:

File Added - 411522: crash.tcl

Attachments: