Thank you. I add "OpenSSL_add_all_algorithms();" in main function and include "openssl/evp.h",but it still pops error dialogue after a while. Some threads can end well, others are not so lucky.
On Sun, Dec 11, 2011 at 8:14 PM, Dr. Stephen Henson <st...@openssl.org>wrote: > On Sun, Dec 11, 2011, cellecial wrote: > > > Hi, > > > > I wrote a simple pkcs12 demo(under Windows), it just read from a > PKCS12 > > file and got private key and certificate. > > If I use single thread, it works fine. > > If I use multi-thread, it works fine for a while ,then popups an > error > > dialogue "heap is corrupt".If I debug it in Visual Studio,it points to > > PKCS12_parse() . > > If I use EnterCriticalSection and LeaveCriticalSection with > > multi-thread, it works fine too, but as you know, the effect is as same > as > > single thread does. > > > > So I want to know , what shared resource is protected by > > CriticalSection? Is PKCS12_parse() not thread-safe? Can it be executed > in > > multi-threads without mutex? > > > > int pkcs12test(unsigned char *p12buf, int p12buflen, unsigned char > *p12pswd) > > { > > PKCS12 *p12; > > X509 *cert; > > EVP_PKEY *prvkey; > > int len; > > char buf[4096]; > > int i=0; > > char desc[1000]; > > > > OpenSSL_add_all_algorithms(); > > > > At least one problem is the above line. You should call > OpenSSL_add_all_algorithm() *once* before starting threads. > > Steve. > -- > Dr Stephen N. Henson. OpenSSL project core developer. > Commercial tech support now available see: http://www.openssl.org > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org >