From patchwork Mon Feb 27 05:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 656879 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2193008wrb; Sun, 26 Feb 2023 22:18:09 -0800 (PST) X-Google-Smtp-Source: AK7set8LcK4T8IRh8NUFFRYaIt8yfqUVkd8nyMcVzuALJF+u7H20oa2pA/acV0StXt+YVOHraVd9 X-Received: by 2002:a05:6214:27eb:b0:56f:6f5:502d with SMTP id jt11-20020a05621427eb00b0056f06f5502dmr40647839qvb.17.1677478689373; Sun, 26 Feb 2023 22:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677478689; cv=none; d=google.com; s=arc-20160816; b=QFEV04b0hWWecbcPc5BV2BG3vA5KsXRuwGPHvNWOYatYmjs2hDSvluGDC+bGLyTCKH brEW6hVEy7kBOpnChfhAEiyTpPOyW2YCTyGzMwNGZhP04VS2q/C2Art+RiY0a0cJswvj 46BsJ0Dit1xXJ1LtK6Sizt/DtAazLzKw8AFrGU5+bjHBSQ9ljKaRIdcSb1qN6NRuIAWd RroKiXvfxlCBKE47ByBWWn9bYiFGdZLC2GTca1J1fzP4PqN4YAb+AQBtsuIG8NGVC10f WqYx0kM68jnTgj2dm5PK9KPSXaHm/STBPz2hdNS2q/LXqwfQ5YNtgwx8p1A7No804CTD 9cyg== 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=SWAZQ5yDYrlUg40T5ma71D5LcqusCfjJqLCC9y6L78eij7viahXfMG+woxIlWtDwMw 8mgoOoz7bVaW9lHHsRrJaCO0HBGIcO3HyPqahQKc0RoaqNgxSr5BYhXU0A+rhA1iF87I W1ydEwwRbBXNUSKvtQ9WiIWbDeFrbHMNYzap+Vw+gF76f/pGBRz+UH4vf4iG3+/bhB8J lqhCtvgd8Z7jBGJHlshVRHJ4JMRCdYvt61ngk9pE+9qW2+U5GrO5fxtnIyVYmmTCJJO/ rlFI2VE6m6h/8TJclYHr+K+hklSTU7iMR4jPQtvApjPxxCBmsPcWogc24vNGYb4NkBo/ 0ihQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GbCQgYK4; 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 ([209.51.188.17]) by mx.google.com with ESMTPS id g11-20020a05620a40cb00b0073bac9cae69si5959885qko.549.2023.02.26.22.18.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Feb 2023 22:18:04 -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=GbCQgYK4; 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 1pWWCH-0001VH-Ac; Mon, 27 Feb 2023 00:37:13 -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 1pWWCF-0001Ph-P1 for qemu-devel@nongnu.org; Mon, 27 Feb 2023 00:37:11 -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 1pWWCD-0002Qe-Va for qemu-devel@nongnu.org; Mon, 27 Feb 2023 00:37:11 -0500 Received: by mail-pl1-x62a.google.com with SMTP id ky4so5570113plb.3 for ; Sun, 26 Feb 2023 21:37:09 -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=GbCQgYK4QIDZXquSfLjwaM8VLvXl3NZfdSR+K7f4x6xbPqUXXCA7G0bJ/NSehLc62F Dy5dzfvd7MGIk11q4Zuo2ARMpBsf5HOCeOKtL7EiqrvpHOHfpZ6n8m/eoSwQrDAZfzH8 z7dfJ7ANSSe17QNY6USFGaRnwqmUfNfvsgJXZFbEnW7oAeKL+pO6eXmppdbmPMcvaoWd Cz4Li5wfB1zJX2lWXlBWeE0b6JgXpkmfaW+XPsmts/oNfe0cwg9UOqa2xI5pCYF6Lm5j ej8L+aEYGRfwoAC/Bqt5rbu/+bT+SNFs51Vu1wBFFYpk0u01qzrr4EB4ibkCNENBN1Rj bNaQ== 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=vKo40GW1pIeQzj3FqszG4IFpqJEuKiwsMKMf3AISguD1P6y4qBVCDfn0j6m8DWT02l mp9t6NqRKv3irgzgilQQYAUlBzWHlfFnWLZ0gav2aiZTh0fODcNY3zvERwU20bneVBBS 6zCpD0RsV4Obdf57Wn721DXCLYwBtC2EedGMiGuXuUqdw9m0DAAlpY0iGC1XMOSeSwkT GtsH6UzLSeCu/MqWCm5hmU+3nSLHeGbterRgKgKq4j63aCny+2e/RvwGNoojrk+EsGdN AGSv+xTUEObf4tprGeMkcTQmoNT6PTcZyaGCGfJITOfaRKTyq1XGK9wAKV0cYecGILoZ cfwA== X-Gm-Message-State: AO0yUKUtDgN8HT201UQ3DWJrrsqZQlEm0qs8IjevLsoyo1D4SuEZ3ZoG s9npmEwfRzpomz7ZfY5fRpsy4PwUezrNR4CHMdk= X-Received: by 2002:a05:6a21:869d:b0:cb:fe3e:e20 with SMTP id ox29-20020a056a21869d00b000cbfe3e0e20mr12752517pzb.42.1677476228549; Sun, 26 Feb 2023 21:37:08 -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 k12-20020aa792cc000000b005a7c892b435sm3342137pfa.25.2023.02.26.21.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 21:37:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, jcmvbkbc@gmail.com, kbastian@mail.uni-paderborn.de, ysato@users.sourceforge.jp, gaosong@loongson.cn, jiaxun.yang@flygoat.com, tsimpson@quicinc.com, ale@rev.ng, mrolnik@gmail.com, edgar.iglesias@gmail.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 01/31] tcg: Adjust TCGContext.temps_in_use check Date: Sun, 26 Feb 2023 19:36:31 -1000 Message-Id: <20230227053701.368744-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230227053701.368744-1-richard.henderson@linaro.org> References: <20230227053701.368744-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=unavailable 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);