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


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

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

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

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

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: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: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:9: 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:415:9: Taking false branch
413.   #endif
414.   
415.       if ((job = ASYNC_get_current_job()) == NULL)
               ^
416.           return;
417.   

engines/e_dasync.c:418:5: 
416.           return;
417.   
418. >     waitctx = ASYNC_get_wait_ctx(job);
419.   
420.       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:420:9: 
418.       waitctx = ASYNC_get_wait_ctx(job);
419.   
420. >     if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
421.                                 (void **)&writefd)) {
422.           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:420:9: Taking false branch
418.       waitctx = ASYNC_get_wait_ctx(job);
419.   
420.       if (ASYNC_WAIT_CTX_get_fd(waitctx, engine_dasync_id, &pipefds[0],
               ^
421.                                 (void **)&writefd)) {
422.           pipefds[1] = *writefd;

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

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)

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

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

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

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

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

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

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

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