Skip to content
Tcl Source Code View Ticket
Login

View Ticket

threads and "would wait forever" message

Closed / Wont Fix1357468fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 17 years ago
Descriptionplain2005-11-15 16:21:27
In unthreaded 8.4 and 8.5, we have the traditional message:

mig@ave:/home/CVS/tcl_SF_clean/unix$ ./tclsh
% vwait a
can't wait for variable "a": would wait forever
%

However, the vwait succeeds in threaded builds.

I'm not sure if this is a bug or not.
dkfplain2005-11-15 23:45:33
Logged In: YES 
user_id=79902

Tcl_ThreadQueueEvent allows an arbitrary thread to inject
events into another arbitrary thread's queue, without being
a formally declared event source. This makes determining
that there are no event sources about somewhat difficult to
say the least...
dkfplain2009-06-18 15:27:27
allow_comments - 1

It would be nice if we could fix this, but it seems that we can't (other than by removing the "would wait forever" message, which isn't the sort of fix I'd approve of) with reasonable effort as it is too awkward to account for all possible event sources in a threaded build. So, no point keeping this issue open.
ferrieuxplain2009-06-18 20:50:20
allow_comments - 0

What about counting other threads, and raising that error only if we are alone ?
IOW, all N-1 others play the role of "suspected event sources"...
dkfplain2009-06-19 15:44:50
allow_comments - 1
ferrieuxplain2009-06-22 15:55:58
Please answer.
ferrieuxplain2009-06-22 15:55:59
allow_comments - 0
nijtmansplain2009-06-22 17:41:25
Well, the fact that dkf put this issue to "WontFix" is an answer ;-)

Let me put my $0.02
The problem with your proposed solution is that the second thread
might not be known to Tcl when the vwait starts. Or maybe the
event is meant to be triggered from a UNIX signal. So the fact
that there are no other Tcl threads, doesn't mean that we would
wait forever.

Yes, this all is highly theoretical. In this case, I am
inclined to agree with dkf, but at least it should still be
documented somewhere......
ferrieuxplain2009-06-22 19:52:34
Thread not created at vwait time: how could that thread start later, then ?

UNIX signal:
 (1) not supported in vanilla tclsh; 
 (2) should be backed by  a registered event source (aren't they in TclX ?)
 (3) Ain't this orthogonal to threads ? How does it behave with TclX in a non-threaded core ?
nijtmansplain2009-06-22 21:24:56
> how could that thread start later, then?
Is there a (portable) way to count threads? If there is, then just
propose a patch, I wound't have a problem with that. Yes, there
must be at least one other thread. Or maybe it is even possible
to create a new thread from within a UNIX signal handler......
Threads and UNIX signals are tricky.

There is no fundamental reason for the "WontFix", merely a
practical one: Someone just needs to put time in it, in order
to implement a solution that solves more problems than that
it possibly creates.
Log in (anonymous is fine) to add a comment.