From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DFE0C1FAF0 for ; Tue, 15 Nov 2022 19:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1668540821; bh=e86vXKU0moPXDorxsKBXCCy2WP9X8Tw+k2HAqSmu8aU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d5Hc+/l54j9j26+sXU5IaMOSotwBqYi8EFooYKB/ZjKZr+gU2YQCAmRhyGwa+jz9u Tk0T5IxNPD56WpLgokuWMq2XC6li28IpkvT/LZVZpsBkQgPSRb1mQykNnIr0MSNdLu N9KCiQ4YOORmr7DGNhtgmN5cyVmsIqvtgsaUnvXU= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 2/6] Devel::Mwrap::reset is a no-op if `totals' not initialized Date: Tue, 15 Nov 2022 19:33:37 +0000 Message-Id: <20221115193341.3948245-3-e@80x24.org> In-Reply-To: <20221115193341.3948245-1-e@80x24.org> References: <20221115193341.3948245-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Don't segfault in case we fail to create rculfhash. --- Mwrap.xs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index 518edb1..e87fe30 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -909,14 +909,15 @@ CODE: rcu_read_lock(); t = CMM_LOAD_SHARED(totals); - cds_lfht_for_each_entry(t, &iter, l, hnode) { - uatomic_set(&l->total, 0); - uatomic_set(&l->allocations, 0); - uatomic_set(&l->frees, 0); - uatomic_set(&l->freed_bytes, 0); - uatomic_set(&l->age_total, 0); - uatomic_set(&l->max_lifespan, 0); - } + if (t) + cds_lfht_for_each_entry(t, &iter, l, hnode) { + uatomic_set(&l->total, 0); + uatomic_set(&l->allocations, 0); + uatomic_set(&l->frees, 0); + uatomic_set(&l->freed_bytes, 0); + uatomic_set(&l->age_total, 0); + uatomic_set(&l->max_lifespan, 0); + } rcu_read_unlock(); Devel::Mwrap::SrcLoc