qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	peterx@redhat.com, Richard Henderson <rth@twiddle.net>,
	"Emilio G . Cota" <cota@braap.org>
Subject: [PATCH v2 2/3] tests/test-rcu-*: Zero-initialize allocated elements
Date: Tue, 14 Oct 2025 15:19:43 -0400	[thread overview]
Message-ID: <20251014191944.2225735-3-peterx@redhat.com> (raw)
In-Reply-To: <20251014191944.2225735-1-peterx@redhat.com>

QEMU almost always do this, so do it too with the RCU unit tests.  It's
preparation work to start asserting on possible rcu double free.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tests/unit/test-rcu-list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/unit/test-rcu-list.c b/tests/unit/test-rcu-list.c
index 8f0adb8b00..853c9e33d9 100644
--- a/tests/unit/test-rcu-list.c
+++ b/tests/unit/test-rcu-list.c
@@ -233,7 +233,7 @@ static void *rcu_q_updater(void *arg)
         TEST_LIST_FOREACH_RCU(el, &Q_list_head, entry) {
             j++;
             if (target_el == j) {
-                struct list_element *new_el = g_new(struct list_element, 1);
+                struct list_element *new_el = g_new0(struct list_element, 1);
                 n_nodes_local++;
                 TEST_LIST_INSERT_AFTER_RCU(el, new_el, entry);
                 break;
@@ -259,7 +259,7 @@ static void rcu_qtest_init(void)
     nthreadsrunning = 0;
     srand(time(0));
     for (i = 0; i < RCU_Q_LEN; i++) {
-        new_el = g_new(struct list_element, 1);
+        new_el = g_new0(struct list_element, 1);
         TEST_LIST_INSERT_HEAD_RCU(&Q_list_head, new_el, entry);
     }
     qemu_mutex_lock(&counts_mutex);
-- 
2.50.1



  parent reply	other threads:[~2025-10-14 19:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 19:19 [PATCH v2 0/3] rcu: Detect accidental reuse of rcu head Peter Xu
2025-10-14 19:19 ` [PATCH v2 1/3] qht: Zero-initialize qht_map Peter Xu
2025-10-14 19:39   ` Philippe Mathieu-Daudé
2025-10-14 19:19 ` Peter Xu [this message]
2025-10-14 19:19 ` [PATCH v2 3/3] rcu: Catch rcu_head misuse Peter Xu
2025-10-15 15:44 ` [PATCH v2 0/3] rcu: Detect accidental reuse of rcu head Richard Henderson

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=20251014191944.2225735-3-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=cota@braap.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /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).