cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Re: What is the proper way to get libcurl to free it resources when used within a C++ Class?

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Tue, 24 Nov 2009 21:17:24 +0100

On Tuesday 24 of November 2009 20:47:30 Dantzler, DeWayne C wrote:
> I'm not calling curl_global_init()/curl_global_cleanup() more than once.

Are you sure? If you call curl_global_init() in a constructor, it's going to
be called per each object creation. Or am I wrong?

> I'm calling them only once. Xerces is a 3rd party library and I have no
> access to the source or know how they are using curl in the their library.

I haven't looked at its code yet, but I doubt they work with curl somehow
wrong (only my subjective estimation).

> This is a large C++ application and I'm using curl in only one class. In my
> ctor, I call curl_global_init() first then make a call to curl_easy_init().
> According to the curl documentation, if you call curl_global_init(), you
> should call curl_global_cleanup(). Likewise it says if you call
> curl_easy_init(), then you should call curl_easy_cleanup(), but when I do
> this the application crashes with a SIGSEGV, Segmentation fault.

Looking at your example again, one thing is clear. You can't call
curl_global_cleanup() before curl_easy_cleanup().

> The call stack shows:
> Results:Program received signal SIGSEGV, Segmentation fault.
> =================================================
> #0 0x63912920 in Curl_cookie_loadfiles+0x9c ()
> #1 0x63933c74 in flush_cookies+0x8c ()
> #2 0x639341ac in Curl_close+0x2ac
> #3 0x639624e8 in curl_easy_cleanup+0x3c ()

From the backtrace above I can't tell immediately what exactly is wrong. You
can just keep it here for about two weeks. Maybe it's more obvious to some
other hackers reading the list. If not, you'll have to write the minimal
example ;-)

Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-24

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET