Details
Description
Hi, developers, thank you for your checking. It seems there is a (potential) deadlock bug in the below code. The function extract_worker_thread_func is not thread-safe, because there is a cyclic acquisition order between the ctxt->mutex and entry->mutex.
{color:#DE350B}extract_worker_thread_func(void *arg) |
{
|
|
while (1) { |
pthread_mutex_lock(ctxt->mutex);
|
...;
|
|
pthread_mutex_lock(&entry->mutex); //ctxt->mutex-->entry->mutex |
|
pthread_mutex_unlock(ctxt->mutex);
|
...;
|
|
if (chunk.type == XB_CHUNK_TYPE_EOF) { |
pthread_mutex_lock(ctxt->mutex); // entry->mutex-> ctxt->mutex |
pthread_mutex_unlock(&entry->mutex);
|
my_hash_delete(ctxt->filehash, (uchar *) entry);
|
pthread_mutex_unlock(ctxt->mutex);
|
|
continue; |
}
|
...;
|
pthread_mutex_unlock(&entry->mutex);
|
}
|
}{color}
|