curl-and-python

OpenSSL thread locking callbacks and segfaults

From: Jayne <corvine_at_gmail.com>
Date: Thu, 22 Jun 2006 17:30:03 +0100

Hi,

I've got a python program using pycurl that regularly segfaults when trying
to download webpages over HTTPS (never over HTTP). I suspect it might be
caused by needing to pass locking callback functions to OpenSSL as here:
http://www.openssl.org/docs/crypto/threads.html - I've included a couple of
stacktraces if anyone could have a look and possibly confirm this? I've
tried to patch pycurl myself to include the callback functions, but I either
haven't done it properly (likely) or that's not the problem as I'm still
getting segfaults. So - is there any chance of a patch for pycurl to include
the locking callback functions in the right places? And if that's not what's
causing my segfaults - any suggestions?

The traceback aren't always the same, but always seem to finish with
lh_free()

#0 0x0043d1c1 in lh_free () from /lib/libcrypto.so.4
#1 0x0043d333 in lh_delete () from /lib/libcrypto.so.4
#2 0x0043fb81 in ERR_set_implementation () from /lib/libcrypto.so.4
#3 0x00440282 in ERR_remove_state () from /lib/libcrypto.so.4
#4 0x0074ca28 in Curl_ossl_close (conn=0x9011d68) at ssluse.c:677
#5 0x0075ae25 in Curl_ssl_close (conn=0x9011d68) at sslgen.c:364
#6 0x00747407 in Curl_disconnect (conn=0x9011d68) at url.c:1542
#7 0x0074b7b6 in Curl_done (connp=0xb0f64a48, status=CURLE_OK) at url.c
:3813
#8 0x00754a2a in Curl_perform (data=0x893dbb0) at transfer.c:2191
#9 0x00754efc in curl_easy_perform (curl=0x893dbb0) at easy.c:444
#10 0x00c7ddce in do_curl_perform (self=0x893d81c) at src/pycurl.c:635
#11 0x080b5f5e in PyEval_EvalFrame (f=0x898ebbc) at Python/ceval.c:3542
#12 0x080b655e in PyEval_EvalFrame (f=0x898ea34) at Python/ceval.c:3640
#13 0x080b655e in PyEval_EvalFrame (f=0x898e89c) at Python/ceval.c:3640
#14 0x080b6f26 in PyEval_EvalCodeEx (co=0xb7f86320, globals=0xb7f9935c,
locals=0x0, args=0xb7f825b8, argcount=1, kws=0x0, kwcount=0, defs=0x0,
defcount=0,
    closure=0x0) at Python/ceval.c:2736
#15 0x080fe02e in function_call (func=0xb7f8e6bc, arg=0xb7f825ac, kw=0x0) at
Objects/funcobject.c:548
#16 0x0805be9c in PyObject_Call (func=0xb7f8e6bc, arg=0xb7f825ac, kw=0x0) at
Objects/abstract.c:1756
#17 0x08064325 in instancemethod_call (func=0xb7f8d7ac, arg=0xb7f825ac,
kw=0x0) at Objects/classobject.c:2447
#18 0x0805be9c in PyObject_Call (func=0xb7f8d7ac, arg=0xb7fb502c, kw=0x0) at
Objects/abstract.c:1756
#19 0x080af2a7 in PyEval_CallObjectWithKeywords (func=0xb7f8d7ac,
arg=0xb7fb502c, kw=0x0) at Python/ceval.c:3425
#20 0x080e32a1 in t_bootstrap (boot_raw=0x89460d0) at
./Modules/threadmodule.c:434
#21 0x0029a371 in start_thread () from /lib/tls/libpthread.so.0
#22 0x0022a9be in clone () from /lib/tls/libc.so.6

#0 0x0043d1c1 in lh_free () from /lib/libcrypto.so.4
#1 0x0043d256 in lh_retrieve () from /lib/libcrypto.so.4
#2 0x0043f973 in ERR_set_implementation () from /lib/libcrypto.so.4
#3 0x004402c7 in ERR_get_state () from /lib/libcrypto.so.4
#4 0x004406c1 in ERR_clear_error () from /lib/libcrypto.so.4
#5 0x004e06df in ssl3_connect () from /lib/libssl.so.4
#6 0x004ed00d in SSL_connect () from /lib/libssl.so.4
#7 0x00e7448c in Curl_ossl_connect (conn=0x98e06d8, sockindex=0) at
ssluse.c:1337
#8 0x00e81af9 in Curl_ssl_connect (conn=0x1, sockindex=-1430939056) at
sslgen.c:203
#9 0x00e676bb in Curl_http_connect (conn=0x98e06d8, done=0x95f8c50 "¸¨(")
at http.c:1371
#10 0x00e6fd93 in Curl_protocol_connect (conn=0x98e06d8,
protocol_done=0xaab5aa1b "") at url.c:2160
#11 0x00e70189 in SetupConnection (conn=0x98e06d8, hostaddr=0x95534b0,
protocol_done=0xaab5aa1b "") at url.c:3673
#12 0x00e7073e in Curl_connect (data=0x94fa7f0, in_connect=0xaab5aa48,
asyncp=0xaab5aa1a "", protocol_done=0xaab5aa1b "") at url.c:3729
#13 0x00e7b5d0 in Curl_connect_host (data=0x94fa7f0, conn=0xaab5aa48) at
transfer.c:2061
#14 0x00e7b807 in Curl_perform (data=0x94fa7f0) at transfer.c:2149
#15 0x00e7befc in curl_easy_perform (curl=0x94fa7f0) at easy.c:444
#16 0x00f76dce in do_curl_perform (self=0x94fa45c) at src/pycurl.c:635
#17 0x080b5f5e in PyEval_EvalFrame (f=0x95529e4) at Python/ceval.c:3542
#18 0x080b655e in PyEval_EvalFrame (f=0x955285c) at Python/ceval.c:3640
#19 0x080b655e in PyEval_EvalFrame (f=0x95526c4) at Python/ceval.c:3640
#20 0x080b6f26 in PyEval_EvalCodeEx (co=0xb7f86320, globals=0xb7f9935c,
locals=0x0, args=0xb7f98298, argcount=1, kws=0x0, kwcount=0, defs=0x0,
defcount=0,
    closure=0x0) at Python/ceval.c:2736
#21 0x080fe02e in function_call (func=0xb7f8e6bc, arg=0xb7f9828c, kw=0x0) at
Objects/funcobject.c:548
#22 0x0805be9c in PyObject_Call (func=0xb7f8e6bc, arg=0xb7f9828c, kw=0x0) at
Objects/abstract.c:1756
#23 0x08064325 in instancemethod_call (func=0xb7f8da2c, arg=0xb7f9828c,
kw=0x0) at Objects/classobject.c:2447
#24 0x0805be9c in PyObject_Call (func=0xb7f8da2c, arg=0xb7fb502c, kw=0x0) at
Objects/abstract.c:1756
#25 0x080af2a7 in PyEval_CallObjectWithKeywords (func=0xb7f8da2c,
arg=0xb7fb502c, kw=0x0) at Python/ceval.c:3425
#26 0x080e32a1 in t_bootstrap (boot_raw=0x9502d10) at
./Modules/threadmodule.c:434
#27 0x0029a371 in start_thread () from /lib/tls/libpthread.so.0
#28 0x0022a9be in clone () from /lib/tls/libc.so.6

Thanks

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2006-06-22