engines/e_dasync.c:509: error: MEMORY_LEAK
  memory dynamically allocated to `writefd` by call to `CRYPTO_malloc()` at line 465, column 19 is not reachable after line 509, column 1.
Showing all 46 steps of the trace


engines/e_dasync.c:444:1: start of procedure dummy_pause_job()
442.   #define DUMMY_CHAR 'X'
443.   
444. > static void dummy_pause_job(void) {
445.       ASYNC_JOB *job;
446.       ASYNC_WAIT_CTX *waitctx;

engines/e_dasync.c:447:5: 
445.       ASYNC_JOB *job;
446.       ASYNC_WAIT_CTX *waitctx;
447. >     OSSL_ASYNC_FD pipefds[2] = {0, 0};
448.       OSSL_ASYNC_FD *writefd;
449.   #if defined(ASYNC_WIN)

engines/e_dasync.c:453:5: 
451.       char buf = DUMMY_CHAR;
452.   #elif defined(ASYNC_POSIX)
453. >     char buf = DUMMY_CHAR;
454.   #endif
455.   

engines/e_dasync.c:456:9: 
454.   #endif
455.   
456. >     if ((job = ASYNC_get_current_job()) == NULL)
457.           return;
458.   

crypto/async/async.c:438:1: start of procedure ASYNC_get_current_job()
  436.   }
  437.   
  438. > ASYNC_JOB *ASYNC_get_current_job(void)
  439.   {
  440.       async_ctx *ctx;

crypto/async/async.c:442:5: 
  440.       async_ctx *ctx;
  441.   
  442. >     ctx = async_get_ctx();
  443.       if(ctx == NULL)
  444.           return NULL;

crypto/async/async.c:102:1: start of procedure async_get_ctx()
    100.   }
    101.   
    102. > async_ctx *async_get_ctx(void)
    103.   {
    104.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))

crypto/async/async.c:104:10: Taking false branch
    102.   async_ctx *async_get_ctx(void)
    103.   {
    104.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
                    ^
    105.           return NULL;
    106.   

crypto/async/async.c:107:5: 
    105.           return NULL;
    106.   
    107. >     return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
    108.   }
    109.   

crypto/threads_pthread.c:120:1: start of procedure CRYPTO_THREAD_get_local()
      118.   }
      119.   
      120. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
      121.   {
      122.       return pthread_getspecific(*key);

crypto/threads_pthread.c:122:5: Skipping pthread_getspecific(): method has no implementation
      120.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
      121.   {
      122.       return pthread_getspecific(*key);
                 ^
      123.   }
      124.   

crypto/threads_pthread.c:123:1: return from a call to CRYPTO_THREAD_get_local
      121.   {
      122.       return pthread_getspecific(*key);
      123. > }
      124.   
      125.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)

crypto/async/async.c:108:1: return from a call to async_get_ctx
    106.   
    107.       return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
    108. > }
    109.   
    110.   static int async_ctx_free(void)

crypto/async/async.c:443:8: Taking false branch
  441.   
  442.       ctx = async_get_ctx();
  443.       if(ctx == NULL)
                ^
  444.           return NULL;
  445.   

crypto/async/async.c:446:5: 
  444.           return NULL;
  445.   
  446. >     return ctx->currjob;
  447.   }
  448.   

crypto/async/async.c:447:1: return from a call to ASYNC_get_current_job
  445.   
  446.       return ctx->currjob;
  447. > }
  448.   
  449.   ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)

engines/e_dasync.c:456:9: Taking false branch
454.   #endif
455.   
456.       if ((job = ASYNC_get_current_job()) == NULL)
               ^
457.           return;
458.   

engines/e_dasync.c:459:5: 
457.           return;
458.   
459. >     waitctx = ASYNC_get_wait_ctx(job);
460.   
461.       if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],

crypto/async/async.c:449:1: start of procedure ASYNC_get_wait_ctx()
  447.   }
  448.   
  449. > ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)
  450.   {
  451.       return job->waitctx;

crypto/async/async.c:451:5: 
  449.   ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)
  450.   {
  451. >     return job->waitctx;
  452.   }
  453.   

crypto/async/async.c:452:1: return from a call to ASYNC_get_wait_ctx
  450.   {
  451.       return job->waitctx;
  452. > }
  453.   
  454.   void ASYNC_block_pause(void)

engines/e_dasync.c:461:9: 
459.       waitctx = ASYNC_get_wait_ctx(job);
460.   
461. >     if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
462.                                 (void **)&writefd)) {
463.           pipefds[1] = *writefd;

crypto/async/async_wait.c:108:1: start of procedure ASYNC_WAIT_CTX_get_fd()
  106.   }
  107.   
  108. > int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
  109.                             OSSL_ASYNC_FD *fd, void **custom_data)
  110.   {

crypto/async/async_wait.c:113:5: 
  111.       struct fd_lookup_st *curr;
  112.   
  113. >     curr = ctx->fds;
  114.       while (curr != NULL) {
  115.           if (curr->del) {

crypto/async/async_wait.c:114:12: Loop condition is false. Leaving loop
  112.   
  113.       curr = ctx->fds;
  114.       while (curr != NULL) {
                    ^
  115.           if (curr->del) {
  116.               /* This one has been marked deleted so do nothing */

crypto/async/async_wait.c:127:5: 
  125.           curr = curr->next;
  126.       }
  127. >     return 0;
  128.   }
  129.   

crypto/async/async_wait.c:128:1: return from a call to ASYNC_WAIT_CTX_get_fd
  126.       }
  127.       return 0;
  128. > }
  129.   
  130.   int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,

engines/e_dasync.c:461:9: Taking false branch
459.       waitctx = ASYNC_get_wait_ctx(job);
460.   
461.       if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
               ^
462.                                 (void **)&writefd)) {
463.           pipefds[1] = *writefd;

engines/e_dasync.c:465:9: 
463.           pipefds[1] = *writefd;
464.       } else {
465. >         writefd = OPENSSL_malloc(sizeof(*writefd));
466.           if (writefd == NULL)
467.               return;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
  117.   }
  118.   
  119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121.       void *ret = NULL;

crypto/mem.c:121:5: 
  119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121. >     void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:126:9: Taking false branch
  124.           return malloc_impl(num, file, line);
  125.   
  126.       if (num <= 0)
                 ^
  127.           return NULL;
  128.   

crypto/mem.c:129:5: 
  127.           return NULL;
  128.   
  129. >     allow_customize = 0;
  130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
  137.       }
  138.   #else
  139. >     osslargused(file); osslargused(line);
  140.       ret = malloc(num);
  141.   #endif

crypto/mem.c:139:24: 
  137.       }
  138.   #else
  139. >     osslargused(file); osslargused(line);
  140.       ret = malloc(num);
  141.   #endif

crypto/mem.c:140:5: 
  138.   #else
  139.       osslargused(file); osslargused(line);
  140. >     ret = malloc(num);
  141.   #endif
  142.   

crypto/mem.c:143:5: 
  141.   #endif
  142.   
  143. >     return ret;
  144.   }
  145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
  142.   
  143.       return ret;
  144. > }
  145.   
  146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

engines/e_dasync.c:466:13: Taking false branch
464.       } else {
465.           writefd = OPENSSL_malloc(sizeof(*writefd));
466.           if (writefd == NULL)
                   ^
467.               return;
468.   #if defined(ASYNC_WIN)

engines/e_dasync.c:474:13: Taking false branch
472.           }
473.   #elif defined(ASYNC_POSIX)
474.           if (pipe(pipefds) != 0) {
                   ^
475.               OPENSSL_free(writefd);
476.               return;

engines/e_dasync.c:479:9: 
477.           }
478.   #endif
479. >         *writefd = pipefds[1];
480.   
481.           if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],

engines/e_dasync.c:481:13: Taking false branch
479.           *writefd = pipefds[1];
480.   
481.           if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],
                   ^
482.                                          writefd, wait_cleanup)) {
483.               wait_cleanup(waitctx, engine_dasync_id, pipefds[0], writefd);

engines/e_dasync.c:495:9: Taking true branch
493.       WriteFile(pipefds[1], &buf, 1, &numwritten, NULL);
494.   #elif defined(ASYNC_POSIX)
495.       if (write(pipefds[1], &buf, 1) < 0)
               ^
496.           return;
497.   #endif

engines/e_dasync.c:496:9: 
494.   #elif defined(ASYNC_POSIX)
495.       if (write(pipefds[1], &buf, 1) < 0)
496. >         return;
497.   #endif
498.   

engines/e_dasync.c:509:1: return from a call to dummy_pause_job
507.           return;
508.   #endif
509. > }
510.   
511.   /*

static void dummy_pause_job(void) {
    ASYNC_JOB *job;
    ASYNC_WAIT_CTX *waitctx;
    OSSL_ASYNC_FD pipefds[2] = {0, 0};
    OSSL_ASYNC_FD *writefd;
#if defined(ASYNC_WIN)
    DWORD numwritten, numread;
    char buf = DUMMY_CHAR;
#elif defined(ASYNC_POSIX)
    char buf = DUMMY_CHAR;
#endif
    if ((job = ASYNC_get_current_job()) == NULL)
        return;
    waitctx = ASYNC_get_wait_ctx(job);
    if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
                              (void **)&writefd)) {
        pipefds[1] = *writefd;
    } else {
        writefd = OPENSSL_malloc(sizeof(*writefd));
        if (writefd == NULL)
            return;
#if defined(ASYNC_WIN)
        if (CreatePipe(&pipefds[0], &pipefds[1], NULL, 256) == 0) {
            OPENSSL_free(writefd);
            return;
        }
#elif defined(ASYNC_POSIX)
        if (pipe(pipefds) != 0) {
            OPENSSL_free(writefd);
            return;
        }
#endif
        *writefd = pipefds[1];
        if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],
                                       writefd, wait_cleanup)) {
            wait_cleanup(waitctx, engine_dasync_id, pipefds[0], writefd);
            return;
        }
    }
#if defined(ASYNC_WIN)
    WriteFile(pipefds[1], &buf, 1, &numwritten, NULL);
#elif defined(ASYNC_POSIX)
    if (write(pipefds[1], &buf, 1) < 0)
        return;
#endif
    ASYNC_pause_job();
#if defined(ASYNC_WIN)
    ReadFile(pipefds[0], &buf, 1, &numread, NULL);
#elif defined(ASYNC_POSIX)
    if (read(pipefds[0], &buf, 1) < 0)
        return;
#endif
}
['static void dummy_pause_job(void) {\n    ASYNC_JOB *job;\n    ASYNC_WAIT_CTX *waitctx;\n    OSSL_ASYNC_FD pipefds[2] = {0, 0};\n    OSSL_ASYNC_FD *writefd;\n#if defined(ASYNC_WIN)\n    DWORD numwritten, numread;\n    char buf = DUMMY_CHAR;\n#elif defined(ASYNC_POSIX)\n    char buf = DUMMY_CHAR;\n#endif\n    if ((job = ASYNC_get_current_job()) == NULL)\n        return;\n    waitctx = ASYNC_get_wait_ctx(job);\n    if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],\n                              (void **)&writefd)) {\n        pipefds[1] = *writefd;\n    } else {\n        writefd = OPENSSL_malloc(sizeof(*writefd));\n        if (writefd == NULL)\n            return;\n#if defined(ASYNC_WIN)\n        if (CreatePipe(&pipefds[0], &pipefds[1], NULL, 256) == 0) {\n            OPENSSL_free(writefd);\n            return;\n        }\n#elif defined(ASYNC_POSIX)\n        if (pipe(pipefds) != 0) {\n            OPENSSL_free(writefd);\n            return;\n        }\n#endif\n        *writefd = pipefds[1];\n        if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],\n                                       writefd, wait_cleanup)) {\n            wait_cleanup(waitctx, engine_dasync_id, pipefds[0], writefd);\n            return;\n        }\n    }\n#if defined(ASYNC_WIN)\n    WriteFile(pipefds[1], &buf, 1, &numwritten, NULL);\n#elif defined(ASYNC_POSIX)\n    if (write(pipefds[1], &buf, 1) < 0)\n        return;\n#endif\n    ASYNC_pause_job();\n#if defined(ASYNC_WIN)\n    ReadFile(pipefds[0], &buf, 1, &numread, NULL);\n#elif defined(ASYNC_POSIX)\n    if (read(pipefds[0], &buf, 1) < 0)\n        return;\n#endif\n}', 'ASYNC_JOB *ASYNC_get_current_job(void)\n{\n    async_ctx *ctx;\n    ctx = async_get_ctx();\n    if(ctx == NULL)\n        return NULL;\n    return ctx->currjob;\n}', 'async_ctx *async_get_ctx(void)\n{\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))\n        return NULL;\n    return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);\n}', 'void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)\n{\n    return pthread_getspecific(*key);\n}', 'ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)\n{\n    return job->waitctx;\n}', 'int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,\n                          OSSL_ASYNC_FD *fd, void **custom_data)\n{\n    struct fd_lookup_st *curr;\n    curr = ctx->fds;\n    while (curr != NULL) {\n        if (curr->del) {\n            curr = curr->next;\n            continue;\n        }\n        if (curr->key == key) {\n            *fd = curr->fd;\n            *custom_data = curr->custom_data;\n            return 1;\n        }\n        curr = curr->next;\n    }\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    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}']