test/asynctest.c:97: error: INTEGER_OVERFLOW_L1
  ([-oo, 0] - 1):unsigned64 by call to `ASYNC_init_thread`.
Showing all 4 steps of the trace


test/asynctest.c:97:17: Call
95.       ASYNC_WAIT_CTX *waitctx = NULL;
96.   
97.       if (       !ASYNC_init_thread(2, 0)
                       ^
98.               || (waitctx = ASYNC_WAIT_CTX_new()) == NULL
99.               || ASYNC_start_job(&job1, waitctx, &funcret1, only_pause, NULL, 0)

crypto/async/async.c:316:1: <LHS trace>
314.   }
315.   
316. > int ASYNC_init_thread(size_t max_size, size_t init_size)
317.   {
318.       async_pool *pool;

crypto/async/async.c:316:1: Parameter `init_size`
  314.   }
  315.   
  316. > int ASYNC_init_thread(size_t max_size, size_t init_size)
  317.   {
  318.       async_pool *pool;

crypto/async/async.c:349:12: Binary operation: ([-oo, 0] - 1):unsigned64 by call to `ASYNC_init_thread` 
  347.   
  348.       /* Pre-create jobs as required */
  349.       while (init_size--) {
                    ^
  350.           ASYNC_JOB *job;
  351.           job = async_job_new();

int ASYNC_init_thread(size_t max_size, size_t init_size)
{
    async_pool *pool;
    size_t curr_size = 0;
    if (init_size > max_size) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
        return 0;
    }
    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
        return 0;
    }
    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
        return 0;
    }
    pool = OPENSSL_zalloc(sizeof *pool);
    if (pool == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    pool->jobs = sk_ASYNC_JOB_new_null();
    if (pool->jobs == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(pool);
        return 0;
    }
    pool->max_size = max_size;
    while (init_size--) {
        ASYNC_JOB *job;
        job = async_job_new();
        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
            async_job_free(job);
            break;
        }
        job->funcargs = NULL;
        sk_ASYNC_JOB_push(pool->jobs, job);
        curr_size++;
    }
    pool->curr_size = curr_size;
    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
        goto err;
    }
    return 1;
err:
    async_free_pool_internal(pool);
    return 0;
}
['static int test_ASYNC_init_thread()\n{\n    ASYNC_JOB *job1 = NULL, *job2 = NULL, *job3 = NULL;\n    int funcret1, funcret2, funcret3;\n    ASYNC_WAIT_CTX *waitctx = NULL;\n    if (       !ASYNC_init_thread(2, 0)\n            || (waitctx = ASYNC_WAIT_CTX_new()) == NULL\n            || ASYNC_start_job(&job1, waitctx, &funcret1, only_pause, NULL, 0)\n                != ASYNC_PAUSE\n            || ASYNC_start_job(&job2, waitctx, &funcret2, only_pause, NULL, 0)\n                != ASYNC_PAUSE\n            || ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)\n                != ASYNC_NO_JOBS\n            || ASYNC_start_job(&job1, waitctx, &funcret1, only_pause, NULL, 0)\n                != ASYNC_FINISH\n            || ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)\n                != ASYNC_PAUSE\n            || ASYNC_start_job(&job2, waitctx, &funcret2, only_pause, NULL, 0)\n                != ASYNC_FINISH\n            || ASYNC_start_job(&job3, waitctx, &funcret3, only_pause, NULL, 0)\n                != ASYNC_FINISH\n            || funcret1 != 1\n            || funcret2 != 1\n            || funcret3 != 1) {\n        fprintf(stderr, "test_ASYNC_init_thread() failed\\n");\n        ASYNC_WAIT_CTX_free(waitctx);\n        ASYNC_cleanup_thread();\n        return 0;\n    }\n    ASYNC_WAIT_CTX_free(waitctx);\n    ASYNC_cleanup_thread();\n    return 1;\n}', 'int ASYNC_init_thread(size_t max_size, size_t init_size)\n{\n    async_pool *pool;\n    size_t curr_size = 0;\n    if (init_size > max_size) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);\n        return 0;\n    }\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {\n        return 0;\n    }\n    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {\n        return 0;\n    }\n    pool = OPENSSL_zalloc(sizeof *pool);\n    if (pool == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    pool->jobs = sk_ASYNC_JOB_new_null();\n    if (pool->jobs == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(pool);\n        return 0;\n    }\n    pool->max_size = max_size;\n    while (init_size--) {\n        ASYNC_JOB *job;\n        job = async_job_new();\n        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {\n            async_job_free(job);\n            break;\n        }\n        job->funcargs = NULL;\n        sk_ASYNC_JOB_push(pool->jobs, job);\n        curr_size++;\n    }\n    pool->curr_size = curr_size;\n    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);\n        goto err;\n    }\n    return 1;\nerr:\n    async_free_pool_internal(pool);\n    return 0;\n}']