Now that threaded builds are default in unix too, one incompatibility suddenly pops out: [vwait] is now unable to report the "would wait forever" error.
This implies that simple scripts that don't use [catch] nor [bgerror], and rely on the starvation of event sources to exit, now deadlock.
Typically: a single fileevent on stdin. Other example: a single, self-reposting [after]. If any error pops out of the handler uncaught, the fileevent handler is disabled, and the [after] handler doesn't repost. Formerly this instructed the script to simply barf "would wait forever" in errorInfo on stderr, and exit. Now it deadlocks forever. This is hard to justify because the script is single-threaded and this regression comes with threading. This kind of 'no-fat' style allows for very short and very readable, powerful event-driven tools. I have many of them in server-side apps, participating in long pipe chains, and a deadlock there is a nightmare.
A solution would be to restore the unthreaded behavior when no Tcl threads have been created.
A more elaborate solution would also take care of non-Tcl "alien threads", signal handlers, and other exotic sources, by using a global, per-process counter that would accumulate:
+1 per fileevent
+1 per timer
+1 for Tk
+1 per thread
+1 per (hypothetical) signal handler, etc...
Then [vwait] would error out "would wait forever" when this counter reaches zero.
I'm giving this a high prio because it is a regression, and the switch to default unthreaded in unix is recent, meaning that some consequences might be pondered again.
|