Skip to content

Commit

Permalink
iothread: Make iothread_stop() idempotent
Browse files Browse the repository at this point in the history
Currently, iothread_stop_all() makes all iothread objects unsafe
to be destroyed, because qemu_thread_join() ends up being called
twice.

To fix this, make iothread_stop() idempotent by checking
thread->stopped.

Fixes the following crash:

  qemu-system-x86_64 -object iothread,id=iothread0 -monitor stdio -display none
  QEMU 2.10.50 monitor - type 'help' for more information
  (qemu) quit
  qemu: qemu_thread_join: No such process
  Aborted (core dumped)

Reported-by: Christian Borntraeger <[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
ehabkost authored and bonzini committed Sep 29, 2017
1 parent cff3e8b commit 65072c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion iothread.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int iothread_stop(Object *object, void *opaque)
IOThread *iothread;

iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
if (!iothread || !iothread->ctx) {
if (!iothread || !iothread->ctx || iothread->stopping) {
return 0;
}
iothread->stopping = true;
Expand Down

0 comments on commit 65072c1

Please sign in to comment.