From patchwork Wed Mar 1 02:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 657763 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp3269654wrb; Tue, 28 Feb 2023 18:59:30 -0800 (PST) X-Google-Smtp-Source: AK7set/BK8KrU7ZDOXy7RcYJ62eWr9CXKt3+4U/oH4tQBQSYfApqX8C8huiHyRllDAAZl+IILXSF X-Received: by 2002:ac8:5b4e:0:b0:3bf:b240:3817 with SMTP id n14-20020ac85b4e000000b003bfb2403817mr8997494qtw.54.1677639569977; Tue, 28 Feb 2023 18:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677639569; cv=none; d=google.com; s=arc-20160816; b=eYXRq0T+hLriG+6spMyZW+ocZlImlA8gUecAHS6RaBbw5FN59RxxbkyD4Bvwt/t8W3 +b3Lg+WD83/WYxX8yNZTs7byHs/c9GBpYmdnSclUo2gd5FmwJJ18zps1IAX7ppoogegL g7IqgWu3ztnAChUx0VYlvLP58yJSUINF4CCl/PAUPxCSpFZorQz1AztLyZB+wE/SZCiH I3n5eixpyDD/Hl99G35mTge9OSEJ2yT6Speaa1mNUMIF2Dyje4wji73Dr+UlCPkjUiXR aB+N4t8MmoIOn2VDUn7J3xggh/eJAYfyya+7On0BZjWkImDaeGoTawwNzqtUbdS+qZSl 8yyw== 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=tz+a4Q6N19bIal6FhX5yvIe/tqM68mxKR4SimMfJ6tI=; b=w8pmvH3nN1j6CN4lGqgjoTv4d3QiEPkMjVTYG+XPUMskGrvlxqnq0XfQlUeuFuzTPf 2A9ryqp84sdRY+d8ALxuDFhO8An4khtPIcXPOjqLdtwnHD8o0iW8bAuRYrvhJqV0KKLk RCXGAHVBJW+0HrwkMSPVVHnzF+E59TIxqKqNgleKvc81xYtaEHPIaGAFROz6ZvFpDv9j dHi1dXHy5ZnMcFvRV99UbDFFoxSrHk8vmsMMo2dbCvl5D6amRqHTGuQbFvr+/s4YLtNt 1NBviGpgGa+iu/y7QCTH/n9inqFzr2fhkofuilbLklkFHacEOkl69RZitE2nMtmxU1SD l5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1MqyZMu; 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 o19-20020a05622a045300b003b9ba906cb4si9972208qtx.538.2023.02.28.18.59.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Feb 2023 18:59:29 -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=g1MqyZMu; 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 1pXCf5-0001zZ-Sq; Tue, 28 Feb 2023 21:57:47 -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 1pXCf2-0001Xe-0a for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:57:44 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXCf0-0003It-Dp for qemu-devel@nongnu.org; Tue, 28 Feb 2023 21:57:43 -0500 Received: by mail-pj1-x1031.google.com with SMTP id m3-20020a17090ade0300b00229eec90a7fso293658pjv.0 for ; Tue, 28 Feb 2023 18:57:42 -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=tz+a4Q6N19bIal6FhX5yvIe/tqM68mxKR4SimMfJ6tI=; b=g1MqyZMuNfROBeR6DDchfV9MT2uAXGBxgmYOtxkKlRXVMFXjYFr79fSSMdWJI0bKFj i5ZyN4+xMw8Cq9yqPlXdO7yP3pVygiBsbIWyYCeSvWLocTb2nYhxjiGsv9es0v73BnTS Zih11zgmICiuyFpdBeS9OwGHsTYIeSW7aADiXTBVkpkH0VwxEu4wtQ1HHcTl+BnZ7aCk 7d80y4/0O7n5nsyrHp3LOXB/ZFmcwAsILGj3nVjybtGtXgYr5aV44PsBLTnzLrX1yUeZ U+WiNioVGZL/BT4vRuqC0/Ca3b+aIahW6s6l5ScXKGN7n2WOXRBOdrZsKgzdQyCzutEy sKlg== 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=tz+a4Q6N19bIal6FhX5yvIe/tqM68mxKR4SimMfJ6tI=; b=Yc4hE2m6jHC7BX+tO/kdsN9hsz2FbU8JPBUFzyxPwi76X/Nc9T/tFjzpJw139Mdhap hjHbHdTNGsoPYVGcmZJFqlELsmb5WGZ+0h00FUWBZ0DSOJTo91QQ5wjK49n4+kZCiT1d nbRkxS8NOAEXSqLM9K3m2tzfSI0BgfCkuG7Uwy3qobnT9GTXEq8q1DUj/t7lt9L+Pp60 sOWO5apdFS3cTxHHsd4GNRpSSlW2X66zmFPqYY8jY5x/ryt0KNlIfCxx/HWtpJZcwg2X P3WHpmVtifPdqZpxdv4AlSqHwwzeSxvHskdcPSQt2T2h5JIUwkprz0mm/lhXKsLPn+qt WWEg== X-Gm-Message-State: AO0yUKWdiSBkpV4/EQRJLhsuK0HSnCJ4nj+9qdKw+8VuXRloZ6sGB/TD T3uCcx4LGkjyZLivPuqDtXg+s3tdwRfi9L5sGAw= X-Received: by 2002:a17:902:e542:b0:19c:b7a9:d4a4 with SMTP id n2-20020a170902e54200b0019cb7a9d4a4mr6220255plf.37.1677639460981; Tue, 28 Feb 2023 18:57:40 -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 jg15-20020a17090326cf00b0019adbef6a63sm7210120plb.235.2023.02.28.18.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 18:57:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 32/62] tcg: Adjust TCGContext.temps_in_use check Date: Tue, 28 Feb 2023 16:56:13 -1000 Message-Id: <20230301025643.1227244-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301025643.1227244-1-richard.henderson@linaro.org> References: <20230301025643.1227244-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 9822c65ea8..855e4cc537 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1374,16 +1374,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);