cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Access Violation in libcurl in Win32 service application on XP

From: Michael Smith <mikes_at_VERTIGO.NET>
Date: Wed, 19 Jan 2005 13:31:46 -0500

Daniel,

I have managed to reproduce the problem and provide a stack trace and hopefully anything else you may need. I will leave my debugger open, and as is until the end of the day.

addrinfo_callback(void * 0x03d6e028, int 0, void * 0x09837c18) line 133 + 3 bytes
Curl_addrinfo4_callback(void * 0x03d6e028, int 0, hostent * 0x09837c18) line 158 + 17 bytes
gethostbyname_thread(void * 0x03d6e028) line 188 + 15 bytes
_threadstartex(void * 0x01a32a30) line 212 + 13 bytes
KERNEL32! 7c80b50b()

WITHIN gethostbyname_thread, it's local variables and there contents are shown below:

conn itself is loaded with garbage values for example bytecount is set to 37662173081632779
conn->async.hostname := 0xcdcdcdcd

he->h_name = "a1458.g.akamai.net"
he->h_aliases = "www.tsr.ch"
he->h_addrtype = 2
he->h_length = 4
he->h_addr_list = "Ñ)ZfÑ)Zhwww.tsr.ch"

static unsigned __stdcall gethostbyname_thread (void *arg)
{
  struct connectdata *conn = (struct connectdata*) arg;
  struct thread_data *td = (struct thread_data*) conn->async.os_specific;
  struct hostent *he;
  int rc;

  /* Sharing the same _iob[] element with our parent thread should
   * hopefully make printouts synchronised. I'm not sure it works
   * with a static runtime lib (MSVC's libc.lib).
   */
  *stderr = *td->stderr_file;

  WSASetLastError (conn->async.status = NO_DATA); /* pending status */
  he = gethostbyname (conn->async.hostname);
  if (he) {
--> Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he); <--- the call stack brings me here
    rc = 1;
  }
  else {
    Curl_addrinfo4_callback(conn, (int)WSAGetLastError(), NULL);
    rc = 0;
  }
  TRACE(("Winsock-error %d, addr %s\n", conn->async.status,
         he ? inet_ntoa(*(struct in_addr*)he->h_addr) : "unknown"));
  return (rc);
  /* An implicit _endthreadex() here */
}

NOTE: It seems that gethostbyname returned a valid pointer to a HOSTENT structure, so I assume at the time of the call to gethostbyname the conn->async.hostname had valid data.

Thanks,

Mike

-----Original Message-----
From: Michael Smith
Sent: Thursday, January 13, 2005 10:18 AM
To: 'libcurl development'
Subject: RE: Access Violation in libcurl in Win32 service application on
XP

Thanks for your response, however as of yet I have not been able to reproduce the problem. A test is running that will eventually reproduce it, but in the meantime I would like know if it is functionally correct to build libcurl in to static library and link it into my application?

There are factors that you may need to know about my application and environment:
- Visual C++ 6.0 SP5.
- WinXP SP2.
- Win32 console application, runs as a service. Production code.
- Multithreaded socket server application.
- Purpose of libcurl in the application is to download video and image content from an internal webserver. The downloads operate on a background thread.

Thanks

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se]On Behalf Of Daniel Stenberg
Sent: Tuesday, January 11, 2005 2:49 PM
To: libcurl development
Subject: Re: Access Violation in libcurl in Win32 service application on
XP

On Tue, 11 Jan 2005, Michael Smith wrote:

> I am receiving an Access Violation and it stems from the following code in
> the curl source code:

And from where was it called? Can you provide a more extensive stack trace? I
figure the 'data' pointer points to somewhere illegal at that point?

> The following code segment is that with which we interface with to make
> calls into the curl lib, hopefully it will give you some insight.

Not a lot - it was very complicated and I can't run it to use my debugger to
figure it out. Can you please try to make a complete and fully working example
source code that shows the problem?

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2005-01-19