From patchwork Sat Feb 25 08:59:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 656435 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1351148wrb; Sat, 25 Feb 2023 01:00:18 -0800 (PST) X-Google-Smtp-Source: AK7set/OB+buHjhTQN5NFFDuw4Cd2wlDRGu63GggXQ+0REYJahWDDOunbbC4F4RTP2MQmExO1jLA X-Received: by 2002:a05:6214:300f:b0:56e:9298:7a1a with SMTP id ke15-20020a056214300f00b0056e92987a1amr4210109qvb.9.1677315618158; Sat, 25 Feb 2023 01:00:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677315618; cv=none; d=google.com; s=arc-20160816; b=QtDckFjLIfjpgnglkCm2iHBz4BajmGOxyyC/PWrkvum301EynkDsLdvcZvfLvKgx7v 0PeGH6NsFZOK36y3IbL2nWgc7bXRn3wiHM6MrIbXdWkNnfnRTQNRX7PqxR8Smu5j0LZy ryM9a7p2abin6wa6UeVkgBWmD20HFxfijQP7bsUpEy1P5SNE5v5zLBLdDunCo24CqAXU tZVSmC7AojFzWSjJNvE6D0zemQegsCY04AsGQKOYtyMJRYo6bBrRU77s+jnpo15uKZPe EdUWVfag2dsgZSqTVOSgfpLCwm1OuO1K6JdRpwGnDSJKPzQMzqM5OdTiAI1JL7n7ZTbc 3FSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oMu/UfowZNJPZ+Z1nOXWigHv/O+5gtKWuTrVMk/F7g0=; b=C72Xt5QnbPnQY9sGCLeZPHTNR8tOAdez837iss1HMjMzzTBlKuA3eRBHmKPMT5poD9 MrC03TckzVu1Z4TqcPsNFqbc6glfk/PTSWWXMf8zI3ysC9PJR/SLnG2dElwco17r1+Ru AD1qKcjKmZUVGMM9fZ8i7eWDYED2DHf7Ooh9fnV8PwGCTtgCRs6e+0cZCt+2xeIxABau MUBEdzKohGfiqswJPLJocjpARlUsecdG62BDD1saREmzITtIAqUCOmQJkAJE40nXYGsv iBYVlmuNX0uHk5jLwTzqvzbmiqnWG99OIVTdOGq7kxWyvzfuSZCXLYgiEvSqUhyiuxCs OchQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EwAQUW0V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ef14-20020a05620a808e00b0071b818675c0si1282215qkb.362.2023.02.25.01.00.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Feb 2023 01:00:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EwAQUW0V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVqPL-0000M2-MK; Sat, 25 Feb 2023 03:59:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVqPJ-0000LO-QU for qemu-devel@nongnu.org; Sat, 25 Feb 2023 03:59:53 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVqPI-0004od-2h for qemu-devel@nongnu.org; Sat, 25 Feb 2023 03:59:53 -0500 Received: by mail-pl1-x62a.google.com with SMTP id i10so1842054plr.9 for ; Sat, 25 Feb 2023 00:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oMu/UfowZNJPZ+Z1nOXWigHv/O+5gtKWuTrVMk/F7g0=; b=EwAQUW0VRgrRYKGBQEn4bdic1J1dHdtG9wOjflv98go3fkM4Jl9KYzdKBlRX7CjQiA 8UOOPk5sB8dA0JgJU0XFgkyHlxp7J6O7Aq8qUQEqaoHL27m3AKUIef6T7M3DA/71DjRy uDwKMSyegv2H5+s5zID2nBWNi5eZuq/cLPJ3bifqvUioXgzHi9sbasxPwa6T0Jm+da+e jgwwKuHLFHNGIlcT6eJF2dyyB3DHu2fYWLvba32/ZHyj4ioADDKqo0PEOf8JXtpS0LEs Ev0UbZjdyvVaC7dtd8tFs3FS3r4wHXe0Mcl/wH+lWZcrnHTrvxU7wFd/svnSsMwYWkSS qcKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oMu/UfowZNJPZ+Z1nOXWigHv/O+5gtKWuTrVMk/F7g0=; b=bhMDXTa3SgkGuyVuPq26svMrqlUdC7op0Zug2TD32A1CfvodC+mH6gn+dGn9eK36i2 KXOTexmlV//Wk2QFJORO6hp1M5OSqH/k37bgEFPR1hl6p9b0WGEt8/i7F1PRwG1T5FIm e8+gt4As5SHQQSMYzYRjpo96mbWehxWymslsHuz5H+5Kq3OqHbBhDDLyD/GhXp+/WIFw UJs/WQlQv6x6iJu0Kjo3mZbt5QLRnDb8CZaUvW40s6COH34QVQgoNeCamubPyMhm/+Ev fWmmFIM+5QGxY0efWGKyQKKcLGVCcFmUDP+cVVEOh5lCiKHGB5yM68tdJLIkxmWm9xvv 3tkQ== X-Gm-Message-State: AO0yUKUSWmPsFv7sEABZgot2iVm8dkci8TIMuE8KR9nrnHO8wqbtPTvl Zuansc02nXNFTvAUGHU6JE9D9fGoKjP4Et22/J0= X-Received: by 2002:a17:90b:268c:b0:234:4187:1acc with SMTP id pl12-20020a17090b268c00b0023441871accmr2417557pjb.19.1677315590742; Sat, 25 Feb 2023 00:59:50 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s17-20020a639251000000b00502ecb91940sm715546pgn.55.2023.02.25.00.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Feb 2023 00:59:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 01/30] tcg: Adjust TCGContext.temps_in_use check Date: Fri, 24 Feb 2023 22:59:16 -1000 Message-Id: <20230225085945.1798188-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230225085945.1798188-1-richard.henderson@linaro.org> References: <20230225085945.1798188-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Change the temps_in_use check to use assert not fprintf. Move the assert for double-free before the check for count, since that is the more immediate problem. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a4a3da6804..06209e6160 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1375,16 +1375,14 @@ void tcg_temp_free_internal(TCGTemp *ts) g_assert_not_reached(); } -#if defined(CONFIG_DEBUG_TCG) - s->temps_in_use--; - if (s->temps_in_use < 0) { - fprintf(stderr, "More temporaries freed than allocated!\n"); - } -#endif - tcg_debug_assert(ts->temp_allocated != 0); ts->temp_allocated = 0; +#if defined(CONFIG_DEBUG_TCG) + assert(s->temps_in_use > 0); + s->temps_in_use--; +#endif + idx = temp_idx(ts); k = ts->base_type + (ts->kind == TEMP_NORMAL ? 0 : TCG_TYPE_COUNT); set_bit(idx, s->free_temps[k].l);