curl-library
Re: Mysterious random crash demystified.
Date: Mon, 11 Oct 2004 18:28:29 +0300 (EEST)
> In that case one must fore the thread to stop. Try if this helps:
> + TerminateThread(td->thread_hnd, 1);
> That should probably be added to Curl_close() somehow.
Well, that has naturally helped, but I for one would be quite reluctant to
implement a TerminateThread for such a small synchronization task. It
would probably do more harm than good.
Excerpt from the reference:
"TerminateThread is a dangerous function that should only be used in the
most extreme cases. You should call TerminateThread only if you know
exactly what the target thread is doing, and you control all of the code
that the target thread could possibly be running at the time of the
termination."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/terminatethread.asp
As is the case, we do not control the code within gethostbyname() and we
may wind up corrupting Winsock or our own running process.
"If the target thread is executing certain kernel32 calls when it is
terminated, the kernel32 state for the thread's process could be
inconsistent."
Received on 2004-10-11