test/lhash_test.c:185: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 179, column 13 is not reachable after line 185, column 9.
Showing all 46 steps of the trace


test/lhash_test.c:167:1: start of procedure test_stress()
165.   }
166.   
167. > static int test_stress(void)
168.   {
169.       LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);

test/lhash_test.c:169:5: 
167.   static int test_stress(void)
168.   {
169. >     LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
170.       const unsigned int n = 2500000;
171.       unsigned int i;

test/lhash_test.c:30:1: start of procedure lh_int_new()
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

test/lhash_test.c:30:1: return from a call to lh_int_new
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

test/lhash_test.c:170:5: 
168.   {
169.       LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
170. >     const unsigned int n = 2500000;
171.       unsigned int i;
172.       int testresult = 0, *p;

test/lhash_test.c:172:5: 
170.       const unsigned int n = 2500000;
171.       unsigned int i;
172. >     int testresult = 0, *p;
173.   
174.       if (!TEST_ptr(h))

test/lhash_test.c:174:10: 
172.       int testresult = 0, *p;
173.   
174. >     if (!TEST_ptr(h))
175.           goto end;
176.   

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/lhash_test.c:174:10: Taking false branch
172.       int testresult = 0, *p;
173.   
174.       if (!TEST_ptr(h))
                ^
175.           goto end;
176.   

test/lhash_test.c:178:10: 
176.   
177.       /* insert */
178. >     for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {

test/lhash_test.c:178:17: Loop condition is true. Entering loop body
176.   
177.       /* insert */
178.       for (i = 0; i < n; i++) {
                       ^
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {

test/lhash_test.c:179:9: 
177.       /* insert */
178.       for (i = 0; i < n; i++) {
179. >         p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {
181.               TEST_info("lhash stress out of memory %d", i);

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
  190.   #endif
  191.   
  192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194.       void *ret = NULL;

crypto/mem.c:194:5: 
  192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194. >     void *ret = NULL;
  195.   
  196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
  195.   
  196.       INCREMENT(malloc_count);
  197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  198.           return malloc_impl(num, file, line);
  199.   

crypto/mem.c:200:9: Taking false branch
  198.           return malloc_impl(num, file, line);
  199.   
  200.       if (num == 0)
                 ^
  201.           return NULL;
  202.   

crypto/mem.c:204:9: Taking true branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
  208.            * allocation.
  209.            */
  210. >         allow_customize = 0;
  211.       }
  212.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:221:5: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:221:19: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:222:5: 
  220.   #else
  221.       (void)(file); (void)(line);
  222. >     ret = malloc(num);
  223.   #endif
  224.   

crypto/mem.c:225:5: 
  223.   #endif
  224.   
  225. >     return ret;
  226.   }
  227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
  224.   
  225.       return ret;
  226. > }
  227.   
  228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/lhash_test.c:180:14: 
178.       for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180. >         if (!TEST_ptr(p)) {
181.               TEST_info("lhash stress out of memory %d", i);
182.               goto end;

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/lhash_test.c:180:14: Taking false branch
178.       for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {
                    ^
181.               TEST_info("lhash stress out of memory %d", i);
182.               goto end;

test/lhash_test.c:184:9: 
182.               goto end;
183.           }
184. >         *p = 3 * i + 1;
185.           lh_int_insert(h, p);
186.       }

test/lhash_test.c:185:9: 
183.           }
184.           *p = 3 * i + 1;
185. >         lh_int_insert(h, p);
186.       }
187.   

test/lhash_test.c:30:1: start of procedure lh_int_insert()
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

crypto/lhash/lhash.c:94:1: start of procedure OPENSSL_LH_insert()
    92.   }
    93.   
    94. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    95.   {
    96.       unsigned long hash;

crypto/lhash/lhash.c:100:5: 
    98.       void *ret;
    99.   
    100. >     lh->error = 0;
    101.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    102.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:101:10: Taking false branch
    99.   
    100.       lh->error = 0;
    101.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                    ^
    102.           return NULL;        /* 'lh->error++' already done in 'expand' */
    103.   

crypto/lhash/lhash.c:104:5: Skipping getrn(): empty list of specs
    102.           return NULL;        /* 'lh->error++' already done in 'expand' */
    103.   
    104.       rn = getrn(lh, data, &hash);
               ^
    105.   
    106.       if (*rn == NULL) {

crypto/lhash/lhash.c:106:9: Taking false branch
    104.       rn = getrn(lh, data, &hash);
    105.   
    106.       if (*rn == NULL) {
                   ^
    107.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    108.               lh->error++;

crypto/lhash/lhash.c:119:9: 
    117.           lh->num_items++;
    118.       } else {                    /* replace same key */
    119. >         ret = (*rn)->data;
    120.           (*rn)->data = data;
    121.           lh->num_replace++;

crypto/lhash/lhash.c:120:9: 
    118.       } else {                    /* replace same key */
    119.           ret = (*rn)->data;
    120. >         (*rn)->data = data;
    121.           lh->num_replace++;
    122.       }

crypto/lhash/lhash.c:121:9: 
    119.           ret = (*rn)->data;
    120.           (*rn)->data = data;
    121. >         lh->num_replace++;
    122.       }
    123.       return ret;

crypto/lhash/lhash.c:123:5: 
    121.           lh->num_replace++;
    122.       }
    123. >     return ret;
    124.   }
    125.   

crypto/lhash/lhash.c:124:1: return from a call to OPENSSL_LH_insert
    122.       }
    123.       return ret;
    124. > }
    125.   
    126.   void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)

test/lhash_test.c:30:1: return from a call to lh_int_insert
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

static int test_stress(void)
{
    LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
    const unsigned int n = 2500000;
    unsigned int i;
    int testresult = 0, *p;
    if (!TEST_ptr(h))
        goto end;
    for (i = 0; i < n; i++) {
        p = OPENSSL_malloc(sizeof(i));
        if (!TEST_ptr(p)) {
            TEST_info("lhash stress out of memory %d", i);
            goto end;
        }
        *p = 3 * i + 1;
        lh_int_insert(h, p);
    }
    if (!TEST_int_eq(lh_int_num_items(h), n))
            goto end;
    TEST_info("hash full statistics:");
    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);
    TEST_note("hash full node usage:");
    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);
    for (i = 0; i < n; i++) {
        const int j = (7 * i + 4) % n * 3 + 1;
        if (!TEST_ptr(p = lh_int_delete(h, &j))) {
            TEST_info("lhash stress delete %d\n", i);
            goto end;
        }
        if (!TEST_int_eq(*p, j)) {
            TEST_info("lhash stress bad value %d", i);
            goto end;
        }
        OPENSSL_free(p);
    }
    TEST_info("hash empty statistics:");
    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);
    TEST_note("hash empty node usage:");
    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);
    testresult = 1;
end:
    lh_int_free(h);
    return testresult;
}
['static int test_stress(void)\n{\n    LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);\n    const unsigned int n = 2500000;\n    unsigned int i;\n    int testresult = 0, *p;\n    if (!TEST_ptr(h))\n        goto end;\n    for (i = 0; i < n; i++) {\n        p = OPENSSL_malloc(sizeof(i));\n        if (!TEST_ptr(p)) {\n            TEST_info("lhash stress out of memory %d", i);\n            goto end;\n        }\n        *p = 3 * i + 1;\n        lh_int_insert(h, p);\n    }\n    if (!TEST_int_eq(lh_int_num_items(h), n))\n            goto end;\n    TEST_info("hash full statistics:");\n    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    TEST_note("hash full node usage:");\n    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    for (i = 0; i < n; i++) {\n        const int j = (7 * i + 4) % n * 3 + 1;\n        if (!TEST_ptr(p = lh_int_delete(h, &j))) {\n            TEST_info("lhash stress delete %d\\n", i);\n            goto end;\n        }\n        if (!TEST_int_eq(*p, j)) {\n            TEST_info("lhash stress bad value %d", i);\n            goto end;\n        }\n        OPENSSL_free(p);\n    }\n    TEST_info("hash empty statistics:");\n    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    TEST_note("hash empty node usage:");\n    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    testresult = 1;\nend:\n    lh_int_free(h);\n    return testresult;\n}', 'DEFINE_LHASH_OF(int)', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))\n        return NULL;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {\n            lh->error++;\n            return NULL;\n        }\n        nn->data = data;\n        nn->next = NULL;\n        nn->hash = hash;\n        *rn = nn;\n        ret = NULL;\n        lh->num_insert++;\n        lh->num_items++;\n    } else {\n        ret = (*rn)->data;\n        (*rn)->data = data;\n        lh->num_replace++;\n    }\n    return ret;\n}']