Skip to content

Commit 278fb16

Browse files
Bauerchenbonzini
authored andcommitted
oslib-posix: take lock before qemu_cond_broadcast
In touch_all_pages, if the mutex is not taken around qemu_cond_broadcast, qemu_cond_broadcast may be called before all touch page threads enter qemu_cond_wait. In this case, the touch page threads wait forever for the main thread to wake them up, causing a deadlock. Signed-off-by: Bauerchen <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9a709f0 commit 278fb16

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

util/oslib-posix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,11 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,
492492
QEMU_THREAD_JOINABLE);
493493
addr += memset_thread[i].numpages * hpagesize;
494494
}
495+
496+
qemu_mutex_lock(&page_mutex);
495497
threads_created_flag = true;
496498
qemu_cond_broadcast(&page_cond);
499+
qemu_mutex_unlock(&page_mutex);
497500

498501
for (i = 0; i < memset_num_threads; i++) {
499502
qemu_thread_join(&memset_thread[i].pgthread);

0 commit comments

Comments
 (0)