test/threadstest.c:87: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 85, column 27 is not reachable after line 87, column 10.
Showing all 37 steps of the trace


test/threadstest.c:83:1: start of procedure test_lock()
81.   #endif
82.   
83. > static int test_lock(void)
84.   {
85.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();

test/threadstest.c:85:5: 
83.   static int test_lock(void)
84.   {
85. >     CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
86.   
87.       if (!TEST_true(CRYPTO_THREAD_read_lock(lock))

crypto/threads_pthread.c:19:1: start of procedure CRYPTO_THREAD_lock_new()
  17.   # endif
  18.   
  19. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  20.   {
  21.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:24:9: 
  22.       CRYPTO_RWLOCK *lock;
  23.   
  24. >     if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
  25.           /* Don't set error, to avoid recursion blowup. */
  26.           return NULL;

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
    226.   }
    227.   
    228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230. >     void *ret = CRYPTO_malloc(num, file, line);
    231.   
    232.       FAILTEST();

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)

crypto/mem.c:233:9: Taking true branch
    231.   
    232.       FAILTEST();
    233.       if (ret != NULL)
                   ^
    234.           memset(ret, 0, num);
    235.       return ret;

crypto/mem.c:234:9: 
    232.       FAILTEST();
    233.       if (ret != NULL)
    234. >         memset(ret, 0, num);
    235.       return ret;
    236.   }

crypto/mem.c:235:5: 
    233.       if (ret != NULL)
    234.           memset(ret, 0, num);
    235. >     return ret;
    236.   }
    237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
    234.           memset(ret, 0, num);
    235.       return ret;
    236. > }
    237.   
    238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:24:9: Taking false branch
  22.       CRYPTO_RWLOCK *lock;
  23.   
  24.       if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
                ^
  25.           /* Don't set error, to avoid recursion blowup. */
  26.           return NULL;

crypto/threads_pthread.c:29:9: Taking false branch
  27.       }
  28.   
  29.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  30.           OPENSSL_free(lock);
  31.           return NULL;

crypto/threads_pthread.c:54:5: 
  52.   # endif
  53.   
  54. >     return lock;
  55.   }
  56.   

crypto/threads_pthread.c:55:1: return from a call to CRYPTO_THREAD_lock_new
  53.   
  54.       return lock;
  55. > }
  56.   
  57.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

test/threadstest.c:87:10: 
85.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
86.   
87. >     if (!TEST_true(CRYPTO_THREAD_read_lock(lock))
88.           || !TEST_true(CRYPTO_THREAD_unlock(lock)))
89.           return 0;

crypto/threads_pthread.c:57:1: start of procedure CRYPTO_THREAD_read_lock()
  55.   }
  56.   
  57. > int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
  58.   {
  59.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:60:9: Taking true branch
  58.   {
  59.   # ifdef USE_RWLOCK
  60.       if (pthread_rwlock_rdlock(lock) != 0)
                ^
  61.           return 0;
  62.   # else

crypto/threads_pthread.c:61:9: 
  59.   # ifdef USE_RWLOCK
  60.       if (pthread_rwlock_rdlock(lock) != 0)
  61. >         return 0;
  62.   # else
  63.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:68:1: return from a call to CRYPTO_THREAD_read_lock
  66.   
  67.       return 1;
  68. > }
  69.   
  70.   int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)

test/threadstest.c:87:10: Condition is false
85.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
86.   
87.       if (!TEST_true(CRYPTO_THREAD_read_lock(lock))
               ^
88.           || !TEST_true(CRYPTO_THREAD_unlock(lock)))
89.           return 0;

test/testutil/tests.c:236:1: start of procedure test_true()
  234.   }
  235.   
  236. > int test_true(const char *file, int line, const char *s, int b)
  237.   {
  238.       if (b)

test/testutil/tests.c:238:9: Taking false branch
  236.   int test_true(const char *file, int line, const char *s, int b)
  237.   {
  238.       if (b)
                 ^
  239.           return 1;
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");

test/testutil/tests.c:240:5: Skipping test_fail_message(): empty list of specs
  238.       if (b)
  239.           return 1;
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
             ^
  241.       return 0;
  242.   }

test/testutil/tests.c:241:5: 
  239.           return 1;
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  241. >     return 0;
  242.   }
  243.   

test/testutil/tests.c:242:1: return from a call to test_true
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  241.       return 0;
  242. > }
  243.   
  244.   int test_false(const char *file, int line, const char *s, int b)

test/threadstest.c:87:10: Taking true branch
85.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
86.   
87.       if (!TEST_true(CRYPTO_THREAD_read_lock(lock))
               ^
88.           || !TEST_true(CRYPTO_THREAD_unlock(lock)))
89.           return 0;

static int test_lock(void)
{
    CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
    if (!TEST_true(CRYPTO_THREAD_read_lock(lock))
        || !TEST_true(CRYPTO_THREAD_unlock(lock)))
        return 0;
    CRYPTO_THREAD_lock_free(lock);
    return 1;
}
['static int test_lock(void)\n{\n    CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();\n    if (!TEST_true(CRYPTO_THREAD_read_lock(lock))\n        || !TEST_true(CRYPTO_THREAD_unlock(lock)))\n        return 0;\n    CRYPTO_THREAD_lock_free(lock);\n    return 1;\n}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n# ifdef USE_RWLOCK\n    CRYPTO_RWLOCK *lock;\n    if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {\n        return NULL;\n    }\n    if (pthread_rwlock_init(lock, NULL) != 0) {\n        OPENSSL_free(lock);\n        return NULL;\n    }\n# else\n    pthread_mutexattr_t attr;\n    CRYPTO_RWLOCK *lock;\n    if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {\n        return NULL;\n    }\n    pthread_mutexattr_init(&attr);\n    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n    if (pthread_mutex_init(lock, &attr) != 0) {\n        pthread_mutexattr_destroy(&attr);\n        OPENSSL_free(lock);\n        return NULL;\n    }\n    pthread_mutexattr_destroy(&attr);\n# endif\n    return lock;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\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}', 'int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)\n{\n# ifdef USE_RWLOCK\n    if (pthread_rwlock_rdlock(lock) != 0)\n        return 0;\n# else\n    if (pthread_mutex_lock(lock) != 0)\n        return 0;\n# endif\n    return 1;\n}', 'int test_true(const char *file, int line, const char *s, int b)\n{\n    if (b)\n        return 1;\n    test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");\n    return 0;\n}']