This patch moves the ExitHandler calls
of Tcl_Finalize() outside of the
TclpInitLock-ed region.
This will avoid deadlocks like the one
seen in Tk Bug 714956, when the
execution of a registered ExitHandler
causes another, nested, call to
Tcl_Finalize().
This patch should be safe, because
the exitHandler loop is careful to always
pull the next handler to run from the
beginning of the loop, and discard each
as it is run, terminating only when the
list is empty.
The rest of Tcl_Finalize(), protected
by a TclpInitLock region, should, we
hope, be prevented from making
a nested call back into Tcl_Finalize().
Please review.
Logged In: YES
user_id=80530
passing on to someone I think
knows Tcl_Finalize() better.
This patch fixes a bug, but does
it cause any new trouble?
Logged In: YES
user_id=95086
I see no obvious problems.
A side-effect, though, is that, when Tcl_Finalize is called
simultaneously by two threads, both of them will execute
exit callbacks. Each exit callback will be run once, but you
never know in which thread this may happen.
Strictly speaking, this should pose no problems, provided that
exit callbacks are really app-wide and do not assume any
thread local storage ownerships and such. Actually, they should
be designed as such in the first place.
Logged In: YES
user_id=80530
Thanks! Applying for 8.4.8 and 8.5.