From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwpbE-0005lC-VW for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwpb9-0000V6-1z for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:08:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51674 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwpb8-0000Uz-SL for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:08:26 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8QD8ENP116463 for ; Tue, 26 Sep 2017 09:08:22 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d7mfkcyrf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 26 Sep 2017 09:08:21 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Sep 2017 14:08:08 +0100 References: <20170926122427.GC4115@localhost.localdomain> <20170926130028.12471-1-ehabkost@redhat.com> From: Christian Borntraeger Date: Tue, 26 Sep 2017 15:08:03 +0200 MIME-Version: 1.0 In-Reply-To: <20170926130028.12471-1-ehabkost@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Message-Id: <62e340df-f56f-3f9c-de5c-9d5bf4df2da8@de.ibm.com> Subject: Re: [Qemu-devel] [PATCH] iothread: Make iothread_stop() idempotent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , Marcel Apfelbaum , Stefan Hajnoczi , Igor Mammedov On 09/26/2017 03:00 PM, Eduardo Habkost wrote: > 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 > Signed-off-by: Eduardo Habkost Tested-by: Christian Borntraeger > --- > iothread.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/iothread.c b/iothread.c > index 44c8944dc4..59d0850988 100644 > --- a/iothread.c > +++ b/iothread.c > @@ -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; >