Fixing a multi-threaded pycurl crash.
Posted
by
Rook
on Stack Overflow
See other posts from Stack Overflow
or by Rook
Published on 2011-01-05T01:45:44Z
Indexed on
2011/01/05
1:54 UTC
Read the original article
Hit count: 309
If I run pycurl in a single thread everything works great. If I run pycurl in 2 threads python will access violate. The first thing I did was report the problem to pycurl, but the project died about 3 years ago so I'm not holding my breath. My (hackish) solution is to build a 2nd version of pycurl called "pycurl_thread" which will only be used by the 2nd thread. I downloaded the pycurl module from sourceforge and I made a total of 4 line changes. But python is still crashing. My guess is that even though this is a module with a different name (import pycurl_thread
), its still sharing memory with the original module (import pycurl
). How should I solve this problem?
Changes in pycurl.c:
initpycurl(void)
to
initpycurl_thread(void)
and
m = Py_InitModule3("pycurl", curl_methods, module_doc);
to
m = Py_InitModule3("pycurl_thread", curl_methods, module_doc);
Changes in setup.py:
PACKAGE = "pycurl"
PY_PACKAGE = "curl"
to
PACKAGE = "pycurl_thread"
PY_PACKAGE = "curl_thread"
Here is the seg fault i'm getting. This is happening within the C function do_curl_perform().
*** longjmp causes uninitialized stack frame ***: python2.7 terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x37)[0x7f209421b537]
/lib/libc.so.6(+0xff4c9)[0x7f209421b4c9]
/lib/libc.so.6(__longjmp_chk+0x33)[0x7f209421b433]
/usr/lib/libcurl.so.4(+0xe3a5)[0x7f20931da3a5]
/lib/libpthread.so.0(+0xfb40)[0x7f209532eb40]
/lib/libc.so.6(__poll+0x53)[0x7f20941f6203]
/usr/lib/libcurl.so.4(Curl_socket_ready+0x116)[0x7f2093208876]
/usr/lib/libcurl.so.4(+0x2faec)[0x7f20931fbaec]
/usr/local/lib/python2.7/dist-packages/pycurl.so(+0x892b)[0x7f209342c92b]
python2.7(PyEval_EvalFrameEx+0x58a1)[0x4adf81]
python2.7(PyEval_EvalCodeEx+0x891)[0x4af7c1]
python2.7(PyEval_EvalFrameEx+0x538b)[0x4ada6b]
python2.7(PyEval_EvalFrameEx+0x65f9)[0x4aecd9]
© Stack Overflow or respective owner