From patchwork Mon Dec 1 17:04:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 788 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608919; bh=QcWbDXUM/y8dNT/F9tgnRPe8XntKuPyBSpJmfGDOXCI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=m+NPlXB2ntO9AHGX3oDrcGCz3JSx2jx7znz2GDOahbN8n9JgEeS3V/r3l6FTxP1rs XUG9fGFmj728m+cTWNCcs1O7zPrlMmYLwnYtr5o581q/zOo+0Ey3Ftjs64YXXv9VyX naMN0Z7r6ACXbRJHuX0fQfm2YnCS9/xnpR4hRgw2j9u1NFcz9dZ/UB5N9kkcX50IjK n+f/cE6nPPKOLS3Gk9jmvvBZiBIBZx3ljOt0gct1oN/sC2nQayTxz0q21iZeeopCi3 Bp5HIClJDMdG8tfh4kxUbl0I54PL37Knw7kZsh4fCmArVQgPLdR80llzIXp0I2A4gw zolGufP//NZ6Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3DC56688A4 for ; Mon, 1 Dec 2025 10:08:39 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zoAu4Pmsh-nY for ; Mon, 1 Dec 2025 10:08:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608919; bh=QcWbDXUM/y8dNT/F9tgnRPe8XntKuPyBSpJmfGDOXCI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=m+NPlXB2ntO9AHGX3oDrcGCz3JSx2jx7znz2GDOahbN8n9JgEeS3V/r3l6FTxP1rs XUG9fGFmj728m+cTWNCcs1O7zPrlMmYLwnYtr5o581q/zOo+0Ey3Ftjs64YXXv9VyX naMN0Z7r6ACXbRJHuX0fQfm2YnCS9/xnpR4hRgw2j9u1NFcz9dZ/UB5N9kkcX50IjK n+f/cE6nPPKOLS3Gk9jmvvBZiBIBZx3ljOt0gct1oN/sC2nQayTxz0q21iZeeopCi3 Bp5HIClJDMdG8tfh4kxUbl0I54PL37Knw7kZsh4fCmArVQgPLdR80llzIXp0I2A4gw zolGufP//NZ6Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0B96E688A7 for ; Mon, 1 Dec 2025 10:08:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608915; bh=0yvIotBPC5NJ98TmyBQrWsC23ift9FDLAb8OBvg/c/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LseQm4u+dcWDZ2JVEjiMjyd7VvTS4oJuZwqF1bAkTcI31WF/G3zS3SddhwBLsTZ8Y axYElnAi6JBKhHWxgTCrQjiXzz4eeqml4F3/6B4C8ztrVSowKhmnCnFJlZ68KuwGad K8wmxrTUFDygoP896T0bZWdBSJtEeNfEQ1CoqmZI7VADXVv+kzY1JbAd78RixnmOd8 eqM38tu6KHIBMmftcqVfm3ZIxrVUEYe0WZKxxqPn+5dr+0ceWctc93cDX7nuUS6LM8 sPcaMBVf4ImJxnpzJentSR1GR5THydT5+/7D0rkf5iliTGgq9P3FemvBgGr4ds1c8I G1o9P1gYw7Lpg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D389968821; Mon, 1 Dec 2025 10:08:35 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bh2XkZLi4bJn; Mon, 1 Dec 2025 10:08:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608911; bh=DUbbS/sdQAnhx1PO2mLmQxVoz79lX0p/wk2LJpNFc3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W2zjaP0TTO1HpYJ5anSbvtmhleLOzk1vCHYJ8jykWPhM8MOMOwVEUu53rqVtNqJPJ TKN3XjvHi7QfAkvR5RZlqAsnZlX5+QM1b8hbnN3FRftFnqqa/sZWhWo2AIMrKMDJuc b/Soct380LTPwni+zktt9hZ8ouWOulB1imJvUzIHeUJ0dfOx+xvTFN1H8jGGmhwl3Y 5RjCdYsPz0sagKot8QGgQhpF1L8/s4HFTd+sr7dTKwY2odl0QdJnyqKlyYJVTs7o41 af3Mpwcz8SgD5UXmDtjAjCgYlekYaAftAJCOvW2UD5WlIoSFhDBE4lzc6+ODE1Eaxh JJ9igzf87gWEw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EEA3A6881A; Mon, 1 Dec 2025 10:08:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 1 Dec 2025 10:04:52 -0700 Message-ID: <20251201170529.3237986-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251201170529.3237986-1-sjg@u-boot.org> References: <20251201170529.3237986-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6UA4TUVFBB5M7PM7X222XYJBQG4GR3EW X-Message-ID-Hash: 6UA4TUVFBB5M7PM7X222XYJBQG4GR3EW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Sean Anderson , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/37] malloc: Enable assertions if UNIT_TEST is enabled List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass dlmalloc has some sanity checks it performs on free() which can help detect memory corruption. However, they are only enabled if DEBUG is defined before including common.h. Define DEBUG earlier if UNIT_TEST is enabled so that assertions are enabled in sandbox. Changes from original commit(s): - Combine commits 213adf6dffe and 1786861415f - Use 'DEBUG 1' instead of 'DEBUG' since new dlmalloc uses '#if DEBUG' Signed-off-by: Sean Anderson Reviewed-by: Simon Glass Co-developed-by: Claude Signed-off-by: Simon Glass (cherry picked from commit 6d7601e74437f3c915667a829ab722ba5174ec72) (cherry picked from commit 1786861415f4494a38630584a8fbc9c939a024ce) --- common/dlmalloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index f0b6db20f5c..98de6523758 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -544,6 +544,10 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP #ifdef __UBOOT__ +#if CONFIG_IS_ENABLED(UNIT_TEST) +#define DEBUG 1 +#endif + #define LACKS_FCNTL_H #define LACKS_UNISTD_H #define LACKS_SYS_PARAM_H