cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Access violation with multi threads

From: Zhen Wang <writewang_at_hotmail.com>
Date: Mon, 25 Nov 2002 17:05:17 +0800

Hi Daniel:
  So sorry for writing back so later. I've solved the problem. I made a
mistake in my program. Since I'm fresh of writing multi-thread program, I
made a common mistake. In a sub-function I create an object in heap, and the
object lunch a new thread. The object is auto-destroyed when the program
exit the sub-function, but the thread is still running and perform access to
the object which has been destroyed already. Then the program causes access
violation and crashes.
The source code listed below:
void CHttpGetDlg::OnBtnstart()
{
  CServerList serverlist;
  serverlist.AddServer("http://www.sian.com.cn");
  serverlist.Craw(); //It lunches new threads, and causes crash.
}

Anyway, thanks for everything, word cannot express my gratitude.
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: Wed, 20 Nov 2002 10:05:24 +0100 (MET)
>
>On Wed, 20 Nov 2002, Zhen Wang wrote:
>
> > 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.
>
>Are you really using curl_easy_init() to get a unique and fresh curl handle
>in each new thread?
>
>--
> 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

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-25