cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Access violation with multi threads

From: Zhen Wang <writewang_at_hotmail.com>
Date: Wed, 20 Nov 2002 09:21:14 +0800

Thank you Daniel! I use curl version 7.10.1£¬ and I built the library uses
VC++ 6.0 with /MDd parameter. I use WINDOWS XP and each thread does the same
thing. It downloads a webpage from a website and extracts links in that
page, and then follows these links to download another webpage. It does
things like a webrobot, such as "Teleport pro". Each thread performs well
with single thread mode but crash each time at the same location when it
performs curl_easy_perform() at the first time. Here is the stack trace:

RASADHLP! 76f91150()
WS2_32! 71a22c60()
Curl_getaddrinfo(SessionHandle * 0x01420068, char * 0x014347bc, int 0, char
* * 0x0161f710) line 653 + 9 bytes
Curl_resolv(SessionHandle * 0x01420068, char * 0x014347bc, int 80) line 256
+ 21 bytes
CreateConnection(SessionHandle * 0x01420068, connectdata * * 0x0161f8d0)
line 2648 + 29 bytes
Curl_connect(SessionHandle * 0x01420068, connectdata * * 0x0161f8d0) line
2795 + 13 bytes
Curl_perform(SessionHandle * 0x01420068) line 1481 + 13 bytes
curl_easy_perform(void * 0x01420068) line 245 + 9 bytes
CServer::Get() line 157 + 12 bytes
StartGet(void * 0x0012e068) line 213
_AfxThreadEntry(void * 0x0012df48) line 112 + 13 bytes
_threadstartex(void * 0x00483f80) line 212 + 13 bytes
KERNEL32! 77e602ed()

---------------------------------

And the program causes the crash:

>76F91150 mov cl,byte ptr [eax] //Access violation
76F91152 inc eax
76F91153 test cl,cl
76F91155 jne 76F91150
76F91157 sub eax,edx
76F91159 mov dword ptr [ebp+8],eax
76F9115C je 76F911B0
76F9115E lea edx,[ebp-604h]
76F91164 mov dword ptr [ebp-608h],3
76F9116E mov eax,esi
76F91170 sub edx,esi

EAX = 014347BC EBX = 00000000
ECX = 77F51B2B EDX = 014347BD
ESI = 014347BC EDI = 71A32224
EIP = 76F91150 ESP = 0161EE8C
EBP = 0161F498 EFL = 00000202 CS = 001B
DS = 0023 ES = 0023 SS = 0023 FS = 0038
GS = 0000 OV=0 UP=0 EI=1 PL=0 ZR=0 AC=0
PE=0 CY=0

--------------------------------------
C++ source:
void CServerList::Get()
{
/* CServer* pServer;
while(pServer=GetServerReadyToGet()){
pServer->Get();
}
*/

// for(int i=0; i<5; i++){
// pThread[i] = AfxBeginThread(StartGet, this);
// }
}

UINT StartCraw(LPVOID pParam){
CServerList* pServerList = (CServerList*)pParam;
CServer* pServer;
while(pServer=pServerList->GetServerReadyToGet()){
pServer->Get();
}
return 0;
}

BOOL CServer::Get()
{
        CHTParse parser;

        curl_easy_setopt(pURL, CURLOPT_FOLLOWLOCATION, 1);
// curl_easy_setopt(pURL, CURLOPT_NOSIGNAL , 1);
        if(pURL==NULL){
                return FALSE;
        }
        bGeting = TRUE;
        while(TRUE){
                int key;
                CURI* pURI;
                BOOL bAllCompleted;
                POSITION position;
                bAllCompleted=TRUE;
                position = mapURL.GetStartPosition();
                while(position){
                        mapURL.GetNextAssoc(position, key, pURI);
                        if(!pURI->IsCompleted()){
                                TRACE("Perform %s\n", pURI->GetAddress());
                                curl_easy_setopt(pURL, CURLOPT_URL, pURI->GetAddress());
                                long lDownloaded = pURI->GetDownloaded();
// if(lDownloaded==0){
                                        double dContentLength;
                                        char* szContentType;
                                        char* szLastURL;

                                        curl_easy_setopt(pURL, CURLOPT_NOBODY, 1);
                                        CURLcode returncode=curl_easy_perform(pURL); // Access violation each
time when perform this line at the first time.

Best regards,
Wang

>From: Daniel Stenberg <daniel_at_haxx.se>
>Reply-To: curl-library_at_lists.sourceforge.net
>To: libcurl Mailing list <curl-library_at_lists.sourceforge.net>
>Subject: Re: Access violation with multi threads
>Date: Tue, 19 Nov 2002 18:04:46 +0100 (MET)
>
>On Wed, 20 Nov 2002, Zhen Wang wrote:
>
> > Hi all, I am confused because my program goes well with single threads
>but
> > occurs access violation while using multi-threads. Since the processes
>are
> > the same, I dont know why this happened. The following is a fragment of
>my
> > program. If I use the code in /* */, everything is OK. But the program
>will
> > crash if I use the lines begin with //. Anyone knows the reasons? Thanks
>in
> > advance.
>
>Please tell us (a lot) more what each thread does, that very tiny snippet
>doesn't offer many clues. Can you get a stack trace from the crash? If so,
>please show us.
>
>What curl version? What operating system? Does it always crash the same
>way?
>
>If nothing else helps, can you please put together a tiny program that
>makes
>the problem appear and post the full source here?
>
>--
> Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by: To learn the basics of securing
>your web site with SSL, click here to get a FREE TRIAL of a Thawte
>Server Certificate: http://www.gothawte.com/rd524.html

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
Received on 2002-11-20