Have you explicitly made your application thread safe?  There are four
functions that you need to implement to make the OpenSSL libraries
themselves thread safe.  These are:

static void locking_function(int mode, int n, const char * file, int line)
static unsigned long id_function(void)
int THREAD_setup(void)
and int THREAD_cleanup

Once you have these implemented, you call THREAD_setup in the main thread
before you start spawning sub threads, and THREAD_cleanup during shutdown.
 This will allow openssl to successfully run the multi threaded.

For more information on how to implement these functions see the man page
for CRYPTO_set_locking_callback, and CRYPTO_set_id_callback

I hope that this is new information, and not something you already knew.

    Cheers,

          Sam

On Tue, Aug 24, 2010 at 6:37 AM, Sayan Chaliha <sayan.chal...@webyog.com>wrote:

> Hey all,
>
> Under stressed conditions (multi-threaded apps with several threads using
> OpenSSL at the same time) the function RAND_bytes crashes consistently.
> Anybody have any idea why this is caused and if there's any solution for it?
>
> Attached:
> GDB `disassemble $rip` ourput from core dump.
>
> Stack trace:
> #0  sha1_block_data_order (c=0x2aab118ab4c0, p=<value optimized out>,
> num=288230376151706362) at sha_locl.h:256
> #1  0x00002b302f4a1e13 in SHA1_Update (c=0x2aab118ab4c0, data_=<value
> optimized out>, len=18446744073709551592) at ../md32_common.h:325
> #2  0x00002b302f5034ed in ssleay_rand_bytes (buf=0x46d25860 "", num=0) at
> md_rand.c:489
> #3  0x00002b302f502df6 in ssleay_rand_pseudo_bytes (buf=0x2022a54d0
> <Address 0x2022a54d0 out of bounds>, num=1933866968) at md_rand.c:533
>
> OpenSSL version: 1.0.0a
>
> OS: CentOS 5.4 x86_64
>
> --
> Regards,
> Sayan Chaliha
> Webyog Softworks Private Limited
> 2nd Floor, Novel Team Building
> #10, 100 Feet Ring Road
> BTM Layout 1st Stage
> Bangalore - 560068
>
> +91-9743357501
>



-- 
Sam Jantz
Software Engineer

Reply via email to