There is a sequence problem in the way how the
win socket/pipe subsystem is teared down. The generic
code which handles the finalization invokes thread
exit handlers first, then finalizes IO subsystem.
Unfortunately, the finalization of the IO subsystem
may access data which is gargabe-collected by the
therad exit handler. In such cases, the application
will either hang or core.
The attached patch works-arround this by moving the
functionality of the thread-exit handler into a
special TclpFinalizeSockets() call. This call is now
part of the generic TclFinalizeIOSubsystem.
This change is no-op for Unix. It affects Windows
(win/) and old Mac-9 (mac/) code bases.