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


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

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

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

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

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

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

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

test/testutil/tests.c:182:1: start of procedure test_ptr()
  180.   }
  181.   
  182. > int test_ptr(const char *file, int line, const char *s, const void *p)
  183.   {
  184.       if (p != NULL)

test/testutil/tests.c:184:9: Taking true branch
  182.   int test_ptr(const char *file, int line, const char *s, const void *p)
  183.   {
  184.       if (p != NULL)
                 ^
  185.           return 1;
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);

test/testutil/tests.c:185:9: 
  183.   {
  184.       if (p != NULL)
  185. >         return 1;
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);
  187.       return 0;

test/testutil/tests.c:188:1: return from a call to test_ptr
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);
  187.       return 0;
  188. > }
  189.   
  190.   int test_true(const char *file, int line, const char *s, int b)

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

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

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

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

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
  156.   #endif
  157.   
  158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160.       void *ret = NULL;

crypto/mem.c:160:5: 
  158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160. >     void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
  160.       void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  163.           return malloc_impl(num, file, line);
  164.   

crypto/mem.c:165:9: Taking false branch
  163.           return malloc_impl(num, file, line);
  164.   
  165.       if (num == 0)
                 ^
  166.           return NULL;
  167.   

crypto/mem.c:169:5: 
  167.   
  168.       FAILTEST();
  169. >     allow_customize = 0;
  170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:179:24: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:180:5: 
  178.   #else
  179.       osslargused(file); osslargused(line);
  180. >     ret = malloc(num);
  181.   #endif
  182.   

crypto/mem.c:183:5: 
  181.   #endif
  182.   
  183. >     return ret;
  184.   }
  185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
  182.   
  183.       return ret;
  184. > }
  185.   
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

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

test/testutil/tests.c:182:1: start of procedure test_ptr()
  180.   }
  181.   
  182. > int test_ptr(const char *file, int line, const char *s, const void *p)
  183.   {
  184.       if (p != NULL)

test/testutil/tests.c:184:9: Taking true branch
  182.   int test_ptr(const char *file, int line, const char *s, const void *p)
  183.   {
  184.       if (p != NULL)
                 ^
  185.           return 1;
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);

test/testutil/tests.c:185:9: 
  183.   {
  184.       if (p != NULL)
  185. >         return 1;
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);
  187.       return 0;

test/testutil/tests.c:188:1: return from a call to test_ptr
  186.       test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);
  187.       return 0;
  188. > }
  189.   
  190.   int test_true(const char *file, int line, const char *s, int b)

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

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

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

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

crypto/lhash/lhash.c:70:1: start of procedure OPENSSL_LH_insert()
    68.   }
    69.   
    70. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    71.   {
    72.       unsigned long hash;

crypto/lhash/lhash.c:76:5: 
    74.       void *ret;
    75.   
    76. >     lh->error = 0;
    77.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    78.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:77:10: Taking false branch
    75.   
    76.       lh->error = 0;
    77.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                   ^
    78.           return NULL;        /* 'lh->error++' already done in 'expand' */
    79.   

crypto/lhash/lhash.c:80:5: Skipping getrn(): empty list of specs
    78.           return NULL;        /* 'lh->error++' already done in 'expand' */
    79.   
    80.       rn = getrn(lh, data, &hash);
              ^
    81.   
    82.       if (*rn == NULL) {

crypto/lhash/lhash.c:82:9: Taking false branch
    80.       rn = getrn(lh, data, &hash);
    81.   
    82.       if (*rn == NULL) {
                  ^
    83.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    84.               lh->error++;

crypto/lhash/lhash.c:96:9: 
    94.       } else {                    /* replace same key */
    95.   
    96. >         ret = (*rn)->data;
    97.           (*rn)->data = data;
    98.           lh->num_replace++;

crypto/lhash/lhash.c:97:9: 
    95.   
    96.           ret = (*rn)->data;
    97. >         (*rn)->data = data;
    98.           lh->num_replace++;
    99.       }

crypto/lhash/lhash.c:98:9: 
    96.           ret = (*rn)->data;
    97.           (*rn)->data = data;
    98. >         lh->num_replace++;
    99.       }
    100.       return (ret);

crypto/lhash/lhash.c:100:5: 
    98.           lh->num_replace++;
    99.       }
    100. >     return (ret);
    101.   }
    102.   

crypto/lhash/lhash.c:101:1: return from a call to OPENSSL_LH_insert
    99.       }
    100.       return (ret);
    101. > }
    102.   
    103.   void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)

test/lhash_test.c:33:1: return from a call to lh_int_insert
  31.   #endif
  32.   
  33. > DEFINE_LHASH_OF(int);
  34.   
  35.   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;
    fprintf(stderr, "hash full statistics:\n");
    OPENSSL_LH_stats((OPENSSL_LHASH *)h, stderr);
    fprintf(stderr, "\nhash full node usage:\n");
    OPENSSL_LH_node_usage_stats((OPENSSL_LHASH *)h, stderr);
    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);
    }
    fprintf(stderr, "\nhash empty statistics:\n");
    OPENSSL_LH_stats((OPENSSL_LHASH *)h, stderr);
    fprintf(stderr, "\nhash empty node usage:\n");
    OPENSSL_LH_node_usage_stats((OPENSSL_LHASH *)h, stderr);
    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    fprintf(stderr, "hash full statistics:\\n");\n    OPENSSL_LH_stats((OPENSSL_LHASH *)h, stderr);\n    fprintf(stderr, "\\nhash full node usage:\\n");\n    OPENSSL_LH_node_usage_stats((OPENSSL_LHASH *)h, stderr);\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    fprintf(stderr, "\\nhash empty statistics:\\n");\n    OPENSSL_LH_stats((OPENSSL_LHASH *)h, stderr);\n    fprintf(stderr, "\\nhash empty node usage:\\n");\n    OPENSSL_LH_node_usage_stats((OPENSSL_LHASH *)h, stderr);\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 [%p] != NULL", s, p);\n    return 0;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    allow_customize = 0;\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    osslargused(file); osslargused(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}']