curl-and-python
segfault/invalid free() in curl_multi.remove_handle()
Date: Wed, 13 Jun 2012 09:12:49 -0400 (EDT)
Hi,
libcurl does not dispatch signals to Python handlers when waiting
for a reply from a dead server (dtto for a proxy or dns).
I understand implementing this properly is not easy, so tried
to work this around with CurlMulti():
- curl.perform()
+ m = pycurl.CurlMulti()
+ m.add_handle(curl)
+ try:
+ while True:
+ if m.perform()[0] == -1: continue
+ num, ok, err = m.info_read()
+ if ok: break
+ if err: raise pycurl.error(*err[0][1:])
+ if m.select(0.1) == -1: raise KeyboardInterrupt
+ finally:
+ m.remove_handle(self.curl_obj)
This mostly works, but there are issues when curl blocks in select()
and I hit ctrl-c. m.remove_handle() then sometimes crashes or triggers
this invalid free():
*** glibc detected *** /usr/bin/python: free(): invalid pointer: 0x08c316b0 ***
======= Backtrace: =========
/lib/libc.so.6[0x87bfb6]
/usr/lib/libcurl.so.4(Curl_http_done+0x9b)[0xae60bb]
/usr/lib/libcurl.so.4(Curl_done+0x106)[0xaf83b6]
/usr/lib/libcurl.so.4(curl_multi_remove_handle+0xfb)[0xb091cb]
/usr/lib/python2.7/site-packages/pycurl.so(+0x3d11)[0x337d11]
I'm using python-pycurl-7.19.0-7.fc14.i686
I can reproduce this almost consistently, but not in a simple setup.
(it depends eg on how much printing was done, etc)
Is this a bug in curl, or the above Python code is wrong?
Thanks,
Zdenek
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2012-06-13