From nobody Wed May 8 01:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506431123874511.4659758226933; Tue, 26 Sep 2017 06:05:23 -0700 (PDT) Received: from localhost ([::1]:47487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwpY6-0003eP-RD for importer@patchew.org; Tue, 26 Sep 2017 09:05:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwpTe-0000lI-4m for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:00:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwpTZ-0004JC-Ap for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:00:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwpTZ-0004HW-3w for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:00:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED28D2C975F; Tue, 26 Sep 2017 13:00:35 +0000 (UTC) Received: from localhost (ovpn-116-64.gru2.redhat.com [10.97.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 860FF784A3; Tue, 26 Sep 2017 13:00:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED28D2C975F Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 26 Sep 2017 10:00:28 -0300 Message-Id: <20170926130028.12471-1-ehabkost@redhat.com> In-Reply-To: <20170926122427.GC4115@localhost.localdomain> References: <20170926122427.GC4115@localhost.localdomain> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 26 Sep 2017 13:00:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] iothread: Make iothread_stop() idempotent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Christian Borntraeger , Stefan Hajnoczi , Igor Mammedov , Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3Diothread0 -monitor stdio -displa= y 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; =20 iothread =3D (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD); - if (!iothread || !iothread->ctx) { + if (!iothread || !iothread->ctx || iothread->stopping) { return 0; } iothread->stopping =3D true; --=20 2.13.5