On Fri, Jun 24, 2011, Yan, Bob wrote:

> Hi,
> 
> I have used IBM purify to check my test program which invokes openssl 
> library. There are some memory leaks reported by Purify, please see below. 
> Could somebody point to me from which function those leaks were generated, 
> and how to avoid those leaks? Thanks, Bob
> 
> 
>          MLK: 1104 bytes leaked in 46 blocks
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                CRYPTO_malloc  [libcrypto.so.1.0.0]
>                ASN1_STRING_type_new [libcrypto.so.1.0.0]
>                ASN1_primitive_new [libcrypto.so.1.0.0]
>                asn1_item_ex_combine_new [libcrypto.so.1.0.0]
>                asn1_item_ex_combine_new [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>          Block of 24 bytes (46 times); last block at 0x2aaaac0f7218
>          MLK: 836 bytes leaked in 2 blocks
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                CRYPTO_malloc  [libcrypto.so.1.0.0]
>                asn1_enc_save  [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>                asn1_template_ex_d2i [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                ASN1_item_d2i  [libcrypto.so.1.0.0]
>          Block of 432 bytes at 0x2aaaac093668
>          Block of 404 bytes at 0x2aaaac009d58
>          MLK: 800 bytes leaked in 20 blocks
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                CRYPTO_malloc  [libcrypto.so.1.0.0]
>                ASN1_OBJECT_new [libcrypto.so.1.0.0]
>                c2i_ASN1_OBJECT [libcrypto.so.1.0.0]
>                asn1_ex_c2i    [libcrypto.so.1.0.0]
>                asn1_d2i_ex_primitive [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>          Block of 40 bytes (20 times); last block at 0x2aaaac097a78
>          MLK: 600 bytes leaked in 15 blocks
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                CRYPTO_malloc  [libcrypto.so.1.0.0]
>                asn1_item_ex_combine_new [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>                asn1_template_ex_d2i [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>          Block of 40 bytes (15 times); last block at 0x2aaaac0f6e98
>          MLK: 376 bytes leaked in 33 blocks
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                CRYPTO_malloc  [libcrypto.so.1.0.0]
>                ASN1_STRING_set [libcrypto.so.1.0.0]
>                asn1_ex_c2i    [libcrypto.so.1.0.0]
>                asn1_d2i_ex_primitive [libcrypto.so.1.0.0]
>                ASN1_item_ex_d2i [libcrypto.so.1.0.0]
>                asn1_template_noexp_d2i [libcrypto.so.1.0.0]
>                asn1_template_ex_d2i [libcrypto.so.1.0.0]
>          Block of 14 bytes (21 times); last block at 0x2aaaac0f7168
>          Block of 12 bytes (2 times); last block at 0x2aaaac096828
>          Block of 11 bytes (2 times); last block at 0x2aaaac096338
>          Block of 5 bytes (6 times); last block at 0x2aaaac0976f8
>          Block of 3 bytes (2 times); last block at 0x2aaaac095e58
>          .
>          .

You can enable the internal leak checking by doing something like:

CRYPTO_memcheck_ctrl(CRYPTO_MEM_CHECK_ON);

then later on:

CRYPTO_mem_leaks(stderr);

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

Reply via email to