From: Yann Collet Date: Tue, 23 Jan 2018 22:03:07 +0000 (-0800) Subject: zstdmt: fixed minor race condition X-Git-Tag: v1.3.4~1^2~67^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de5e38a7a60ef80f4e71838df87cea15c5e15047;p=thirdparty%2Fzstd.git zstdmt: fixed minor race condition no real consequence, but pollute tsan tests : job->dstBuff is being modified inside worker, while main thread might read it accidentally because it copies whole job. But since it doesn't used dstBuff, there is no real consequence. Other potential solution : only copy useful data, instead of whole job --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index be683e83f..922839810 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -344,7 +344,9 @@ void ZSTDMT_compressChunk(void* jobDescription) job->cSize = ERROR(memory_allocation); goto _endJob; } + ZSTD_PTHREAD_MUTEX_LOCK(job->jobCompleted_mutex); /* note : it's a mtctx mutex */ job->dstBuff = dstBuff; + ZSTD_pthread_mutex_unlock(job->jobCompleted_mutex); } /* init */