From patchwork Tue Dec 3 15:42:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 296216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ED6472C00A4 for ; Wed, 4 Dec 2013 02:42:55 +1100 (EST) Received: from localhost ([::1]:43066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vns7g-0005mh-Tx for incoming@patchwork.ozlabs.org; Tue, 03 Dec 2013 10:42:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vns7F-0005kj-BL for qemu-devel@nongnu.org; Tue, 03 Dec 2013 10:42:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vns79-0000qW-QE for qemu-devel@nongnu.org; Tue, 03 Dec 2013 10:42:25 -0500 Received: from mail-qa0-x230.google.com ([2607:f8b0:400d:c00::230]:33171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vns79-0000qQ-M2 for qemu-devel@nongnu.org; Tue, 03 Dec 2013 10:42:19 -0500 Received: by mail-qa0-f48.google.com with SMTP id w5so5757064qac.0 for ; Tue, 03 Dec 2013 07:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=empImvaDYdx+BGbGiOIymFpEDP2aJ0sjxGbXDe9qi68=; b=biBBpOUs+DYMJ4VAu28lk0V967GxTPYAEOv/k2PynVmWqlNM/2Z1jTUIB6jjzsbE1Y WmxmN7DtL04bbQ35APKGpbae8D2pDV27sfw7RNu7QRAZ9xkzEedBxApQ0waGceRPL40O 9goBB6IqJemhVoydxAir0A8dLoCeHzazDZ5lfYAPS3MbfwJ6nDtZ7MojB2FFTWhiDe/9 +jfpbT0+HQUKMceviByCg2YMpd+wsL4sPB7+hO8/iLFWj7gbV5N9vp5eFHV/muAZe1wl 9jzdgY/WpeQk0Srw3J/2yqfHL7NfbWjNN+jrZ7uAF/riAPjz30juqqKzcGRbScu6YJ6n 61Eg== X-Received: by 10.224.136.136 with SMTP id r8mr99579879qat.0.1386085339200; Tue, 03 Dec 2013 07:42:19 -0800 (PST) Received: from yakj.usersys.redhat.com (net-2-35-202-54.cust.dsl.vodafone.it. [2.35.202.54]) by mx.google.com with ESMTPSA id ki4sm7862358qeb.0.2013.12.03.07.42.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2013 07:42:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 3 Dec 2013 16:42:00 +0100 Message-Id: <1386085320-12965-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1386085320-12965-1-git-send-email-pbonzini@redhat.com> References: <1386085320-12965-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::230 Cc: peter.crosthwaite@xilinx.com, hpoussin@reactos.org, afaerber@suse.de Subject: [Qemu-devel] [PATCH 2/2] qom: detect bad reentrance during object_class_foreach X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hervé Poussineau We should not modify the type hash table while it is being iterated on. Assert that it does not happen. Signed-off-by: Hervé Poussineau Signed-off-by: Paolo Bonzini --- qom/object.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qom/object.c b/qom/object.c index 3a43186..1dee9f0 100644 --- a/qom/object.c +++ b/qom/object.c @@ -78,8 +78,10 @@ static GHashTable *type_table_get(void) return type_table; } +static bool enumerating = false; static void type_table_add(TypeImpl *ti) { + assert(!enumerating); g_hash_table_insert(type_table_get(), (void *)ti->name, ti); } @@ -666,7 +668,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), { OCFData data = { fn, implements_type, include_abstract, opaque }; + enumerating = true; g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data); + enumerating = false; } int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),