Skip to content
  • Anthony PERARD's avatar
    f4f71363
    thread-pool: signal "request_cond" while locked · f4f71363
    Anthony PERARD authored
    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: 900fa208 ("thread-pool: replace semaphore with condition variable")
    Signed-off-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230714152720.5077-1-anthony.perard@citrix.com>
    Signed-off-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
    f4f71363
    thread-pool: signal "request_cond" while locked
    Anthony PERARD authored
    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: 900fa208 ("thread-pool: replace semaphore with condition variable")
    Signed-off-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230714152720.5077-1-anthony.perard@citrix.com>
    Signed-off-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
Loading