cURL / Mailing Lists / curl-library / Single Mail

curl-library

Correct use of curl_easy_getinfo

From: Till Elsner <till_at_0xaa55.org>
Date: Mon, 5 Dec 2011 13:45:30 +0100

Hi,

I keep running into trouble with using curl_easy_getinfo:
I'm using the same CURL handle for multiple connections. Before
every new connection request, I reset the handle using
curl_easy_reset. Afterwards, I set the options for the handle
using curl_easy_setopt (CURLOPT_URL, CURLOPT_FOLLOWLOCATION to
1, CURLOPT_WRITEFUNCTION, CURLOPT_WRITEDATA,
CURLOPT_ERRORBUFFER) and call curl_easy_perform. So far, this
works fine. But when I call curl_easy_getinfo on the handle
after having fetched the site to get the effective URL, I still
works for the FIRST connection. However, on the next connection
using the same handle, the program receives segmentation fault
while performing curl_easy_perform. The following backtrace from
gdb shows what's going on (or does it?):

#0 0x00007ffff740d933 in malloc_consolidate () from
/lib64/libc.so.6
#1 0x00007ffff740f655 in _int_malloc () from /lib64/libc.so.6
#2 0x00007ffff7413222 in calloc () from /lib64/libc.so.6
#3 0x00007ffff7b8a25b in allocate_conn (data=0x6a0be0) at
url.c:3527
#4 0x00007ffff7b8c43e in create_conn (data=0x6a0be0,
in_connect=0x7fffffffdd58, async=0x7fffffffdd0b) at url.c:4719
#5 0x00007ffff7b8cf3c in Curl_connect (data=0x6a0be0,
in_connect=0x7fffffffdd58, asyncp=0x7fffffffdd0b,
protocol_done=0x7fffffffdd0a) at url.c:5148
#6 0x00007ffff7b9ca18 in connect_host (data=0x6a0be0,
conn=0x7fffffffdd58) at transfer.c:1971
#7 0x00007ffff7b9ccf7 in Curl_do_perform (data=0x6a0be0) at
transfer.c:2105
#8 0x00007ffff7b9d067 in Curl_perform (data=0x6a0be0) at
transfer.c:2251
#9 0x00007ffff7b9d9de in curl_easy_perform (curl=0x6a0be0) at
easy.c:567
#10 0x000000000040336e in open_url (url=0x6dc4e0 "code/",
curl=0x6a0be0) at url.c:25
#11 0x00000000004020b6 in main (argc=2, argv=0x7fffffffe078) at
main.c:209

(Don't get confused by url.c in #10, this is from my own source
code, it's not the url.c from libcurl).

Where is my mistake? How is libcurl (curl_easy_getinfo) used
correctly?

Thanks and regards
Till

-- 
Till Elsner                                                   []
till_at_0xAA55.org (Email & XMPP)                                  []
irc.0xaa55.org #praty                                       [][][]
############################## GPG ###############################
#                      KeyID=0xFCFF4656                          #
# fingerprint: 1A1E 3B61 6956 07E3 2CB8 D0F8 791F 52F8 FCFF 4656 #
##################################################################
 ()  ascii ribbon campaign  - against html e-mail
 /\   www.asciiribbon.org   - against proprietary attachments

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

  • application/pgp-signature attachment: stored
Received on 2011-12-05