[dictBuilder] Fix deadlock in *COVER error case

The COVER and FASTCOVER dictionary builders can deadlock when
dictionary construction errors, likely because there are too few
samples, or too few distinct dmers. The deadlock only occurs when
there are errors.

Fixes #1746.
This commit is contained in:
Nick Terrell 2019-08-26 18:19:29 -07:00
parent d0750a1c9c
commit 0932de54bc

View File

@ -919,13 +919,12 @@ void COVER_best_finish(COVER_best_t *best, ZDICT_cover_params_t parameters,
} }
} }
/* Save the dictionary, parameters, and size */ /* Save the dictionary, parameters, and size */
if (!dict) { if (dict) {
return; memcpy(best->dict, dict, dictSize);
best->dictSize = dictSize;
best->parameters = parameters;
best->compressedSize = compressedSize;
} }
memcpy(best->dict, dict, dictSize);
best->dictSize = dictSize;
best->parameters = parameters;
best->compressedSize = compressedSize;
} }
if (liveJobs == 0) { if (liveJobs == 0) {
ZSTD_pthread_cond_broadcast(&best->cond); ZSTD_pthread_cond_broadcast(&best->cond);