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


engines/e_dasync.c:401:1: start of procedure dummy_pause_job()
399.   #define DUMMY_CHAR 'X'
400.   
401. > static void dummy_pause_job(void) {
402.       ASYNC_JOB *job;
403.       ASYNC_WAIT_CTX *waitctx;

engines/e_dasync.c:404:5: 
402.       ASYNC_JOB *job;
403.       ASYNC_WAIT_CTX *waitctx;
404. >     OSSL_ASYNC_FD pipefds[2] = {0, 0};
405.       OSSL_ASYNC_FD *writefd;
406.   #if defined(ASYNC_WIN)

engines/e_dasync.c:410:5: 
408.       char buf = DUMMY_CHAR;
409.   #elif defined(ASYNC_POSIX)
410. >     char buf = DUMMY_CHAR;
411.   #endif
412.   

engines/e_dasync.c:413:9: 
411.   #endif
412.   
413. >     if ((job = ASYNC_get_current_job()) == NULL)
414.           return;
415.   

crypto/async/async.c:394:1: start of procedure ASYNC_get_current_job()
  392.   }
  393.   
  394. > ASYNC_JOB *ASYNC_get_current_job(void)
  395.   {
  396.       async_ctx *ctx;

crypto/async/async.c:398:5: 
  396.       async_ctx *ctx;
  397.   
  398. >     ctx = async_get_ctx();
  399.       if(ctx == NULL)
  400.           return NULL;

crypto/async/async.c:58:1: start of procedure async_get_ctx()
    56.   }
    57.   
    58. > async_ctx *async_get_ctx(void)
    59.   {
    60.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))

crypto/async/async.c:60:10: Taking false branch
    58.   async_ctx *async_get_ctx(void)
    59.   {
    60.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
                   ^
    61.           return NULL;
    62.   

crypto/async/async.c:63:5: 
    61.           return NULL;
    62.   
    63. >     return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
    64.   }
    65.   

crypto/threads_pthread.c:79:1: start of procedure CRYPTO_THREAD_get_local()
      77.   }
      78.   
      79. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
      80.   {
      81.       return pthread_getspecific(*key);

crypto/threads_pthread.c:81:5: Skipping pthread_getspecific(): method has no implementation
      79.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
      80.   {
      81.       return pthread_getspecific(*key);
                ^
      82.   }
      83.   

crypto/threads_pthread.c:82:1: return from a call to CRYPTO_THREAD_get_local
      80.   {
      81.       return pthread_getspecific(*key);
      82. > }
      83.   
      84.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)

crypto/async/async.c:64:1: return from a call to async_get_ctx
    62.   
    63.       return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
    64. > }
    65.   
    66.   static int async_ctx_free(void)

crypto/async/async.c:399:8: Taking false branch
  397.   
  398.       ctx = async_get_ctx();
  399.       if(ctx == NULL)
                ^
  400.           return NULL;
  401.   

crypto/async/async.c:402:5: 
  400.           return NULL;
  401.   
  402. >     return ctx->currjob;
  403.   }
  404.   

crypto/async/async.c:403:1: return from a call to ASYNC_get_current_job
  401.   
  402.       return ctx->currjob;
  403. > }
  404.   
  405.   ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)

engines/e_dasync.c:413:9: Taking false branch
411.   #endif
412.   
413.       if ((job = ASYNC_get_current_job()) == NULL)
               ^
414.           return;
415.   

engines/e_dasync.c:416:5: 
414.           return;
415.   
416. >     waitctx = ASYNC_get_wait_ctx(job);
417.   
418.       if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],

crypto/async/async.c:405:1: start of procedure ASYNC_get_wait_ctx()
  403.   }
  404.   
  405. > ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)
  406.   {
  407.       return job->waitctx;

crypto/async/async.c:407:5: 
  405.   ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)
  406.   {
  407. >     return job->waitctx;
  408.   }
  409.   

crypto/async/async.c:408:1: return from a call to ASYNC_get_wait_ctx
  406.   {
  407.       return job->waitctx;
  408. > }
  409.   
  410.   void ASYNC_block_pause(void)

engines/e_dasync.c:418:9: 
416.       waitctx = ASYNC_get_wait_ctx(job);
417.   
418. >     if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
419.                                 (void **)&writefd)) {
420.           pipefds[1] = *writefd;

crypto/async/async_wait.c:65:1: start of procedure ASYNC_WAIT_CTX_get_fd()
  63.   }
  64.   
  65. > int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,
  66.                             OSSL_ASYNC_FD *fd, void **custom_data)
  67.   {

crypto/async/async_wait.c:70:5: 
  68.       struct fd_lookup_st *curr;
  69.   
  70. >     curr = ctx->fds;
  71.       while (curr != NULL) {
  72.           if (curr->del) {

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

crypto/async/async_wait.c:84:5: 
  82.           curr = curr->next;
  83.       }
  84. >     return 0;
  85.   }
  86.   

crypto/async/async_wait.c:85:1: return from a call to ASYNC_WAIT_CTX_get_fd
  83.       }
  84.       return 0;
  85. > }
  86.   
  87.   int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,

engines/e_dasync.c:418:9: Taking false branch
416.       waitctx = ASYNC_get_wait_ctx(job);
417.   
418.       if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
               ^
419.                                 (void **)&writefd)) {
420.           pipefds[1] = *writefd;

engines/e_dasync.c:422:9: 
420.           pipefds[1] = *writefd;
421.       } else {
422. >         writefd = OPENSSL_malloc(sizeof(*writefd));
423.           if (writefd == NULL)
424.               return;

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
  69.   }
  70.   
  71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73.       void *ret = NULL;

crypto/mem.c:73:5: 
  71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73. >     void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:78:9: Taking false branch
  76.           return malloc_impl(num, file, line);
  77.   
  78.       if (num <= 0)
                ^
  79.           return NULL;
  80.   

crypto/mem.c:81:5: 
  79.           return NULL;
  80.   
  81. >     allow_customize = 0;
  82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:91:24: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:92:5: 
  90.   #else
  91.       osslargused(file); osslargused(line);
  92. >     ret = malloc(num);
  93.   #endif
  94.   

crypto/mem.c:95:5: 
  93.   #endif
  94.   
  95. >     return ret;
  96.   }
  97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
  94.   
  95.       return ret;
  96. > }
  97.   
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

engines/e_dasync.c:423:13: Taking false branch
421.       } else {
422.           writefd = OPENSSL_malloc(sizeof(*writefd));
423.           if (writefd == NULL)
                   ^
424.               return;
425.   #if defined(ASYNC_WIN)

engines/e_dasync.c:431:13: Taking false branch
429.           }
430.   #elif defined(ASYNC_POSIX)
431.           if (pipe(pipefds) != 0) {
                   ^
432.               OPENSSL_free(writefd);
433.               return;

engines/e_dasync.c:436:9: 
434.           }
435.   #endif
436. >         *writefd = pipefds[1];
437.   
438.           if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],

engines/e_dasync.c:438:13: Taking false branch
436.           *writefd = pipefds[1];
437.   
438.           if(!ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_dasync_id, pipefds[0],
                   ^
439.                                          writefd, wait_cleanup)) {
440.               wait_cleanup(waitctx, engine_dasync_id, pipefds[0], writefd);

engines/e_dasync.c:452:9: Taking true branch
450.       WriteFile(pipefds[1], &buf, 1, &numwritten, NULL);
451.   #elif defined(ASYNC_POSIX)
452.       if (write(pipefds[1], &buf, 1) < 0)
               ^
453.           return;
454.   #endif

engines/e_dasync.c:453:9: 
451.   #elif defined(ASYNC_POSIX)
452.       if (write(pipefds[1], &buf, 1) < 0)
453. >         return;
454.   #endif
455.   

engines/e_dasync.c:466:1: return from a call to dummy_pause_job
464.           return;
465.   #endif
466. > }
467.   
468.   /*

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}']