Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-11-04
23:01 • Ticket [1078024fff] threaded exit can reinit PipeInit on exit and crash stat... artifact: 54b4811f1e user: kennykb
23:01 • Ticket [1078024fff]: 5 changes artifact: c67bb93b01 user: kennykb
23:01 • Closed ticket [1078024fff]. artifact: 2ba9de6b29 user: kennykb
2005-11-02
00:11 • Ticket [1078024fff]: 5 changes artifact: 1b622e5e1c user: dgp
2005-03-04
14:29 • Ticket [1078024fff]: 4 changes artifact: 8ea053f4eb user: mistachkin
2004-12-03
00:08 • New ticket [1078024fff]. artifact: b454f25052 user: hobbs

threaded exit can reinit PipeInit on exit and crash

Closed / Fixed1078024fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 21 years ago
Descriptionplain2004-12-03 00:08:10
There is an issue with finalization of the threaded
Windows build that can appear in winDde.test and
occasionally winPipe.test.  Kevin narrowed it down to
this series of events:

* Tcl_Finalize is called from Tcl_Exit and runs all the
exit handlers.

* After all the exit handlers are run, it winds up
calling Tcl_FinalizeThread.

* From there we get into Tcl_FinalizeIOSubsystem, and
thence to Tcl_Close

* We have an open pipe at this point, so we get into
PipeClose2Proc from tclWinPipe.c.

* This calls Tcl_CleanupChildren -> Tcl_WaitPid

* and Tcl_WaitPid finds that the pipe subsystem isn't
initialized - because its exit handler has already run,
so calls PipeInit, re-establishing the exit handler.

* Now we shut down the zippy memory allocator - with
the exit handler still on the list.

* The last-ditch Tcl_Finalize in DLL_PROCESS_DETACH
finds the exit handler and runs it - and then frees the
memory.

* Which is now in use as a CRITICAL_SECTION down in the
C runtime... boom.

* I believe that it's a threaded problem only, and the
exit handler is being created in Windows-specific code.

* I don't know if there's similar code in Unix.

This is perhaps related to 990457 (this is unix
specific, but about threaded exit behavior)
mistachkinplain2005-03-04 14:29:40
Logged In: YES 
user_id=113501

Argle.  I bet this is causing a number of issues I've been
seeing on Win32.  

Unfortunately, I do not know enough about how the IO
subsystem is supposed to work.

This bug is only loosely related to bug 990457, if at all.
This bug is almost certainly related to bug 912571.
dgpplain2005-11-02 00:11:51
Logged In: YES 
user_id=80530


Have the finalization fixes since
the last comment resolved this one?
kennykb Closed ticket [1078024fff]. [History diff]2005-11-04 23:01:38
kennykbplain2005-11-04 23:01:39
Logged In: YES 
user_id=99768

I would presume that it's fixed by my commits of 2005-06-22.
The controversial panic in Tcl_Finalize to guard against
creating
an exit handler after exit handlers have already run should
protect us against having this problem recur.
kennykb Ticket [1078024fff]: 2 changes [History diff]2005-11-04 23:01:40
Log in (anonymous is fine) to add a comment.