From: Yann Collet Date: Sun, 2 Feb 2025 05:23:36 +0000 (-0800) Subject: fixed one race scenario X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4279%2Fhead;p=thirdparty%2Fzstd.git fixed one race scenario --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 91f158084..68f911149 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -837,6 +837,7 @@ _endJob: job->cSize += lastCBlockSize; job->consumed = job->src.size; /* when job->consumed == job->src.size , compression job is presumed completed */ if (job->flush_mutex != NULL) { + assert(job->flush_cond != NULL); ZSTD_pthread_mutex_unlock(&job->job_mutex); ZSTD_PTHREAD_MUTEX_LOCK(job->flush_mutex); ZSTD_pthread_cond_signal(job->flush_cond); /* warns some more data is ready to be flushed */ @@ -1603,8 +1604,6 @@ static size_t ZSTDMT_flushProduced(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, u DEBUGLOG(5, "dstBuffer released"); mtctx->jobs[wJobID].dstBuff = g_nullBuffer; mtctx->jobs[wJobID].cSize = 0; /* ensure this job slot is considered "not started" in future check */ - mtctx->jobs[wJobID].flush_mutex = NULL; - mtctx->jobs[wJobID].flush_cond = NULL; mtctx->consumed += srcSize; mtctx->produced += cSize; mtctx->doneJobID++; diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index b8290fefc..e87a52328 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c @@ -2900,7 +2900,7 @@ static int fuzzerTests_newAPI(U32 seed, int nbTests, int startTest, U32 lseed; int opaqueAPI; const BYTE* srcBuffer; - size_t totalTestSize, totalGenSize, cSize; + size_t totalTestSize, totalGenSize, cSize=0; XXH64_state_t xxhState; U64 crcOrig; U32 resetAllowed = 1;