qemu/util
Anthony PERARD f4f71363fc thread-pool: signal "request_cond" while locked
thread_pool_free() might have been called on the `pool`, which would
be a reason for worker_thread() to quit. In this case,
`pool->request_cond` is been destroyed.

If worker_thread() didn't managed to signal `request_cond` before it
been destroyed by thread_pool_free(), we got:
    util/qemu-thread-posix.c:198: qemu_cond_signal: Assertion `cond->initialized' failed.

One backtrace:
    __GI___assert_fail (assertion=0x55555614abcb "cond->initialized", file=0x55555614ab88 "util/qemu-thread-posix.c", line=198,
	function=0x55555614ad80 <__PRETTY_FUNCTION__.17104> "qemu_cond_signal") at assert.c:101
    qemu_cond_signal (cond=0x7fffb800db30) at util/qemu-thread-posix.c:198
    worker_thread (opaque=0x7fffb800dab0) at util/thread-pool.c:129
    qemu_thread_start (args=0x7fffb8000b20) at util/qemu-thread-posix.c:505
    start_thread (arg=<optimized out>) at pthread_create.c:486

Reported here:
    https://lore.kernel.org/all/ZJwoK50FcnTSfFZ8@MacBook-Air-de-Roger.local/T/#u

To avoid issue, keep lock while sending a signal to `request_cond`.

Fixes: 900fa208f5 ("thread-pool: replace semaphore with condition variable")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230714152720.5077-1-anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
2023-08-01 10:22:33 +01:00
..
aio-posix.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
aio-posix.h aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
aio-wait.c
aio-win32.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
aiocb.c
async-teardown.c os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option 2023-07-10 15:34:57 +02:00
async.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
atomic64.c
base64.c
bitmap.c
bitops.c
block-helpers.c
block-helpers.h
buffer.c
bufferiszero.c
cacheflush.c util/cacheflush: Avoid possible redundant dcache flush on Darwin 2023-06-13 11:28:58 +02:00
compatfd.c
coroutine-sigaltstack.c
coroutine-ucontext.c
coroutine-windows.c
cpuinfo-aarch64.c host/include/aarch64: Implement aes-round.h 2023-07-08 07:30:17 +01:00
cpuinfo-i386.c host/include/i386: Implement aes-round.h 2023-07-08 07:30:17 +01:00
cpuinfo-ppc.c host/include/ppc: Implement aes-round.h 2023-07-08 07:30:17 +01:00
crc-ccitt.c
crc32c.c
cutils.c cutils: Improve qemu_strtosz handling of fractions 2023-06-02 12:29:27 -05:00
dbus.c
drm.c
envlist.c
error-report.c
error.c
event_notifier-posix.c
event_notifier-win32.c
fdmon-epoll.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
fdmon-io_uring.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
fdmon-poll.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
fifo8.c
filemonitor-inotify.c
filemonitor-stub.c
getauxval.c
guest-random.c cutils: Adjust signature of parse_uint[_full] 2023-06-02 12:27:19 -05:00
hbitmap.c
hexdump.c
host-utils.c
id.c
int128.c
interval-tree.c util/interval-tree: Use qatomic_read/set for rb_parent_color 2023-07-31 12:19:13 -07:00
iov.c util/iov: Remove qemu_iovec_init_extended() 2023-06-05 13:11:24 +02:00
iova-tree.c
keyval.c
lockcnt.c
log.c util/log: Add vector registers to log 2023-06-13 17:42:01 +10:00
main-loop.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
memalign.c
memfd.c
meson.build util: Add cpuinfo-ppc.c 2023-07-08 07:30:17 +01:00
mmap-alloc.c
module.c
notify.c
nvdimm-utils.c
osdep.c
oslib-posix.c
oslib-win32.c console/win32: allocate shareable display surface 2023-06-27 17:08:56 +02:00
path.c
qdist.c
qemu-co-shared-resource.c
qemu-co-timeout.c
qemu-config.c
qemu-coroutine-io.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
qemu-coroutine-lock.c atomics: eliminate mb_read/mb_set 2023-06-06 09:42:14 +02:00
qemu-coroutine-sleep.c
qemu-coroutine.c
qemu-option.c
qemu-print.c
qemu-progress.c
qemu-sockets.c cutils: Adjust signature of parse_uint[_full] 2023-06-02 12:27:19 -05:00
qemu-thread-common.h
qemu-thread-posix.c
qemu-thread-win32.c
qemu-timer-common.c
qemu-timer.c
qht.c
qsp.c accel/tcg: include cs_base in our hash calculations 2023-06-01 11:05:05 -04:00
qtree.c
range.c
rcu.c
readline.c
selfmap.c
stats64.c
sys_membarrier.c
systemd.c
thread-context.c
thread-pool.c thread-pool: signal "request_cond" while locked 2023-08-01 10:22:33 +01:00
throttle.c
timed-average.c
trace-events console/win32: allocate shareable display surface 2023-06-27 17:08:56 +02:00
trace.h
transactions.c
unicode.c
uri.c
userfaultfd.c
uuid.c
vfio-helpers.c
vhost-user-server.c aio: remove aio_disable_external() API 2023-05-30 17:37:26 +02:00
yank.c