On Fri, Feb 20, 2004, Alberto Alonso wrote:

> I'm trying to use openssl-0.9.7a-23 (the RPM from Fedora 1)
> in a multithreaded environment.
> 
> Basically I have a server with about 5 worker threads and 
> a client with a varying number of threads that connect to
> the server.
> 
> When using around 20 threads at the client I can't see any 
> problems.
> 
> But when the client increases to around 150 threads the client
> segfaults.
> 
> The server never segfaults.
> 
> The gdb trace is:
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1431196752 (LWP 15771)]
> 0x00620b84 in _int_malloc () from /lib/tls/libc.so.6
> (gdb) where
> #0  0x00620b84 in _int_malloc () from /lib/tls/libc.so.6
> #1  0x0062170a in _int_realloc () from /lib/tls/libc.so.6
> #2  0x0062012f in realloc () from /lib/tls/libc.so.6
> #3  0x00b70307 in OpenSSLDie () from /lib/libcrypto.so.4
> #4  0x00b70a06 in CRYPTO_realloc () from /lib/libcrypto.so.4
> #5  0x00bb84f4 in lh_doall_arg () from /lib/libcrypto.so.4
> #6  0x00bb8248 in lh_insert () from /lib/libcrypto.so.4
> #7  0x00000001 in ?? ()
> #8  0x00c17210 in CAST_S_table7 () from /lib/libcrypto.so.4
> #9  0x000001c4 in ?? ()
> (
> 
> Within main I do the calls to:
> 
>   CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
>   CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
> 
> One thing I'm not sure from the documentation is whether or not
> the ctx can be shared across multiple threads. At this point I
> am using a pointer to the same ctx everywhere and call the SSL_new
> each time a connection needs encrypting.
> 
> Any ideas as to where I need to be looking to figure this out?
> 

Looks like a race condition of some sort.

Well first thing I'd suggest is using the latest 0.9.7 snapshot and seeing if
you still have the problem.

Also compile OpenSSL with debugging symbols so the precise location of the
crash (if it stil happens) can be determined.

There should be no problems using the same SSL_CTX among multiple threads. If
however you mean an EVP_CIPHER_CTX each thread should have its own because
state information is stored in there.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to