Re: Tcl [exit] hanging?
- From: George Peter Staplin <georgeps@xxxxxxxxxxxx>
- Date: Sun, 12 Apr 2009 04:24:44 -0600
Troy wrote:
On Apr 9, 5:02 pm, Jeff Godfrey <jeff_godf...@xxxxxxxxx> wrote:
rocket777 wrote:
Just noticed, that twapii::end_process also allows for an optional
exit code too!!
http://twapi.magicsplat.com/process.html#end_process
Great. I'll look into it. While I'd certainly like to get to the
bottom of the real issue, maybe that'll at least buy me some time.
Thanks.
Jeff
We've also seen this problem at work. We were using TclBlend, and so
we worked around it similarly, by exiting using the java system exit
command instead of tcl exit. Seeing this today prompted me to ask my
coworker who investigated this (we had been plagued by this for
years), and he filed a bug (http://sourceforge.net/tracker/?
func=detail&aid=2750491&group_id=10894&atid=110894) that contains more
information on what he found about it and how to possibly work around
it.
I suspect the commit below may have fixed it in 8.6. There was some
questionable code in tclWin32Dll.c. I recall we discussed it at the
Tcler's Chat at some length. Joe English in particular was quite against
the code pattern, because of the problems it could introduce, and the MSDN
documentation warned against what Tcl was doing.
2008-08-01 Jeff Hobbs <jeffh@xxxxxxxxxxxxxxx>
* doc/Exit.3: Do not call Tcl_Finalize implicitly
* generic/tclEvent.c: on DLL_PROCESS_DETACH as it may lead
* win/tclWin32Dll.c (DllMain): to issues and the user should be
explicitly calling Tcl_Finalize before unloading regardless. Clarify
the docs to note the explicit need in embedded use.
So it's quite possible the code before lead to some races, or parts of the
Windows DLL code causing a deadlock.
This is what the MSDN documentation has to say about what Tcl was doing:
"Calling functions that require DLLs other than Kernel32.dll may result in
problems that are difficult to diagnose. For example, calling User, Shell,
and COM functions can cause access violation errors, because some functions
load other system components. Conversely, calling functions such as these
during termination can cause access violation errors because the
corresponding component may already have been unloaded or uninitialized.
Because DLL notifications are serialized, entry-point functions should not
attempt to communicate with other threads or processes. *Deadlocks* may
occur as a result."
See also: http://msdn.microsoft.com/en-us/library/ms682583.aspx
The emphasis on "Deadlocks" was added by me.
As far as I know Tcl uses multiple threads in Windows, and so does Tk for
Windows. The code that Tcl_Finalize uses manipulates and cleans up a lot
of global thread state, and that was unsafe to do from a DLL_PROCESS_DETACH
path. It was also using DLLs other than Kernel32.dll.
In fact the developer that added it seems to have known some of that, based
on the comment in see in 8.5.
" * Side effects:
* Establishes 32-to-16 bit thunk and initializes sockets library. This
* might call some sycronization functions, but MSDN documentation
* states: "Waiting on synchronization objects in DllMain can cause a
* deadlock."
In other words, the code was flawed, and the person that added it really
shouldn't have.
-George
.
- References:
- Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: George Peter Staplin
- Re: Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: George Peter Staplin
- Re: Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: rocket777
- Re: Tcl [exit] hanging?
- From: rocket777
- Re: Tcl [exit] hanging?
- From: Jeff Godfrey
- Re: Tcl [exit] hanging?
- From: Troy
- Tcl [exit] hanging?
- Prev by Date: Re: open office *.odt files
- Next by Date: Re: open office *.odt files
- Previous by thread: Re: Tcl [exit] hanging?
- Next by thread: Re: Tcl [exit] hanging?
- Index(es):
Relevant Pages
|