qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v4 2/8] qom: detect bad reentrance during object_class_foreach
Date: Wed, 11 Dec 2013 21:22:15 +1100	[thread overview]
Message-ID: <1386757341-12154-3-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1386757341-12154-1-git-send-email-aik@ozlabs.ru>

From: Hervé Poussineau <hpoussin@reactos.org>

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 <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v4:
* rename: @enumerating -> @enumerating_types
* @enumerating_types is static and does not require initialization to "false"
---
 qom/object.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qom/object.c b/qom/object.c
index 3a43186..937af00 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_types;
 static void type_table_add(TypeImpl *ti)
 {
+    assert(!enumerating_types);
     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_types = true;
     g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
+    enumerating_types = false;
 }
 
 int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
-- 
1.8.4.rc4

  parent reply	other threads:[~2013-12-11 10:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 10:22 [Qemu-devel] [PATCH v4 0/8] spapr: bootindex support Alexey Kardashevskiy
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 1/8] qom: do not register interface "types" in the type table Alexey Kardashevskiy
2013-12-11 10:22 ` Alexey Kardashevskiy [this message]
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 3/8] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 4/8] spapr-llan: add to boot device list Alexey Kardashevskiy
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 5/8] spapr-vio: fix firmware names Alexey Kardashevskiy
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 6/8] qdev: introduce FWPathProvider interface Alexey Kardashevskiy
2014-02-20 12:01   ` Andreas Färber
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 7/8] vl: allow customizing the class of /machine Alexey Kardashevskiy
2013-12-11 10:22 ` [Qemu-devel] [PATCH v4 8/8] spapr: define interface to fix device pathname Alexey Kardashevskiy
2013-12-11 10:36 ` [Qemu-devel] [PATCH v4 0/8] spapr: bootindex support Paolo Bonzini
2013-12-12 14:05 ` Michael S. Tsirkin
2013-12-13  3:19   ` Alexey Kardashevskiy
2014-01-22  4:19 ` Alexey Kardashevskiy
2014-01-22 10:16   ` Paolo Bonzini
2014-01-22 12:17     ` Alexey Kardashevskiy
2014-02-14  3:25       ` Alexey Kardashevskiy
2014-02-14  7:29         ` Paolo Bonzini
2014-02-14  8:26           ` Alexey Kardashevskiy
2014-02-20  8:37             ` Alexey Kardashevskiy
2014-02-20 11:09               ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386757341-12154-3-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=agraf@suse.de \
    --cc=hpoussin@reactos.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).