Nobody responded, but for the sake of record posterity (in case anyone searches for said bug), I fixed the issue by placing a mutex around the initialization code. This way each thread initializes the CTX without competing. This eliminates the bug. Someone more familiar with the library, and with more time than myself might want to dig further.
Other references to this bug in the archive : http://www.mail-archive.com/[EMAIL PROTECTED]/msg34647.html L~ My Previous Message ------ First the basics, I am running openssl-0.9.7d, compiled on a WBEL system, using ./config (linux-elf was the result), with -DOPENSSL_THREADS & -DPURIFY, so my dev library plays nice with valgrind. The problem arises when I try to multi-thread my application. Valgrind produces this output : ==27982== Thread 7: ==27982== Invalid write of size 4 ==27982== at 0x80765A9: lh_insert (in /home/ladar/Projects/program/src/program) ==27982== by 0xB7370505: thread_wrapper (vg_libpthread.c:667) ==27982== by 0xB741083A: do__quit (vg_scheduler.c:2146) ==27982== Address 0xB608D090 is 308 bytes inside a block of size 1024 free'd ==27982== at 0xB74D3C2C: realloc (vg_replace_malloc.c:310) ==27982== by 0x806D132: default_realloc_ex (in /home/ladar/Projects/program/src/program) Can anyone tell me why my threads aren't playing nicely with each other? None of the openssl related code is hit until after the threads are spawned. In other words, each thread has its own : SSL_CTX, SSL, SSL_METHOD, & BIO. They do share the same socket, but I use accept to create a specific socket which is then passed to SSL_accept : // Lock the accept function, and get a new connection. pthread_mutex_lock(&ssl_accept_mutex); temp_sock_descriptor = accept(*sock_descriptor, (struct sockaddr *)&pin, (socklen_t *)&address_size); if (temp_sock_descriptor == -1) { quiet_log(0, NULL, "accept returned an error code, in waiter_ssl"); printf("Error while accepting connection.\n"); exit(1); } pthread_mutex_unlock(&ssl_accept_mutex); // Setup the SSL object. sbio = BIO_new_socket(temp_sock_descriptor, BIO_NOCLOSE); ssl = SSL_new(ctx); state = SSL_accept(ssl); SSL_set_bio(ssl, sbio, sbio); Can someone help me out here? Thanks, L~ ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]