curl-library
Re: Re[2]: gethostbyname_thread: Access Violation
Date: Mon, 22 Aug 2005 14:00:15 +0200
"Igor Polyakov" wrote:
> Curl_destroy_thread_data is called in my code from curl_easy_cleanup,
> I have checked it using breakpoint. td->thread_id within Curl_destroy_thread_data
> had value equal to the second thread id. I see that this function do
> some cleanup, but I feel it does not wait until second thread
> terminates...
I build your program as:
cl -I../include -Zi -GZ -Yd -MDd -D_DEBUG -DCURL_STATICLIB
thread-crash.cpp libcurld.lib wsock32.lib winmm.lib
I ran it on cmdline and in VS debugger. No problem on cmdline. But
debugging it shows that the resolver thread isn't started until you call
Sleep() !. Note that GetCurrentProcess() returns -1, which I assume
means the parent app. or main thread is gone.
Try with the following patch:
Index: hostthre.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/hostthre.c,v
retrieving revision 1.24
diff -u -r1.24 hostthre.c
--- hostthre.c 14 Jun 2005 14:47:21 -0000 1.24
+++ hostthre.c 22 Aug 2005 11:57:35 -0000
@@ -184,6 +184,9 @@
HANDLE mutex_waiting = NULL;
HANDLE curr_proc = GetCurrentProcess();
+ if (curr_proc == INVALID_HANDLE_VALUE)
+ return -1;
+
if (!DuplicateHandle(curr_proc, td->mutex_waiting,
curr_proc, &mutex_waiting, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
@@ -252,6 +255,9 @@
HANDLE mutex_waiting = NULL;
HANDLE curr_proc = GetCurrentProcess();
+ if (curr_proc == INVALID_HANDLE_VALUE)
+ return -1;
+
if (!DuplicateHandle(curr_proc, td->mutex_waiting,
curr_proc, &mutex_waiting, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
--gv
Received on 2005-08-22