From patchwork Sat Jan 3 01:18:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1206 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=1767403214; bh=e40qGDU32VOmSCPOxM08N/gYNwycYkXN1lFU4GROPpQ=; 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=NApe4R9pjK+UJ0thdBQHhxCcHpLYe4pjumo3S2RSwN52Mt1pOPdJ0jarAlBXJ6NjO A+9o8TYwKvYd9B8ylGbgp+tbh5Q+M4pSc2G4URZqehbJff07eA0JySMVYby0afEM/N XzxjY1MY5H2raDoibnyaWgH0QxRuerWlIl0SVXOqf4D5o4rqjgJ/g8U4NKS4FweG9F J6vKmQJOjb2oyU4xjDnqu8Vdf9i3MyFrp/r8es+ngtdw5iz4JEdrwEW0xv/qPk1E1u Wvg2QbjdshMeEaAS1fecqldVROy7SxcoQGW2zNOjdBIAV4o9YTZbW65qdsiD+eI4fe JhVCP/NNaRr+A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9800069068 for ; Fri, 2 Jan 2026 18:20:14 -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 H_fvjI6I1Ga2 for ; Fri, 2 Jan 2026 18:20:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403212; bh=e40qGDU32VOmSCPOxM08N/gYNwycYkXN1lFU4GROPpQ=; 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=irh9co4NXKq+uInHsm/guLsaaSJ8VLwxUhDcG1DNJAM73RKnrS2+qEidGuFaUSFsW SHPogbVbdj2cI+bfsW23TAnG4SSgXJ6A0uyFl04dNAfIeJcPlEyjQuCoOJd3pSlZNS /U5ZTtN/JSpDW1HQ8lopHeZgwcjEyGgUqIP2uML11uVst4z18v2rODUZn+gQSV1Jny ZlOPNl4c6YPqcZyLYmuCTkpFf4ZJT1RDco8aeTDaQI/Ujphu8CqYFTcj4B1gTg6pNF iIuSVXQvBL102mcAGwgvKeNKraexzw2KBRmS3vE9xokQsx8ldKxDsm/WILPyuYYcIg 9yshHfS8lSlAg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93DE168F87 for ; Fri, 2 Jan 2026 18:20:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403210; bh=gwCbcsVw9G7esfHYN/MqIGimB1/Hi7OFUtQK1XEFyJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B5hubAKSlEfZqQ6miQHy+n231opQefluINzysgVY+QEx8q+gqvuWL99wcw13yzCJc 5CPrYqIX77W1DCA1AXggVUOhVu7b5+TiYxh+1H5hzNo6NIdvq95J9X/penl2sucv06 qsDwq4xNSaoTOYZ5WlFwydmEVpb8f2aY8C101MRBaS9+gUvLqNlWUV1d7Rj0tMacXO BQDfeGDnIYMCTAc5NsCVc7fnutq3pWcC1BCVoYV2p62Oejd0dqLh3/kF59XshicesY nDs1P0twwf64JBu9mMrB44YWtILyy8BUUqV6EYVpY2vcCdiycJAREEaRlEFCIY8bn6 rv2YBILDmGybg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3360068BF2; Fri, 2 Jan 2026 18:20:10 -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 7BJGmkjjIqX7; Fri, 2 Jan 2026 18:20:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403208; bh=edaM7C2i2qY7W/LJ6/ny/n+zNVmtpU5X0U3aW1mCxiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h9HuV4pA6BhvBTqpZXG5yc41QHqoVtdPyqv0BcEeKE0190+YP2QBXEVvLygg3djIU GJwM6/DTw6JmEkAuuTVtvuaxaVYfJqqY+ucOOQz0j833MKRufSmF9weAtcKGD6ea3V MqLZWaA4UtZoTUV+2IgSfO9lcSUm0HptEa/RjObrDZSDeNkiMAhchsX2189tCYx5Sk 0KcINHtc3sJD+qqiYeIvtlL/X/vxct9XGaP8TztnPEEQaNB1L6Qe8BjjUahQH4LqDV hmvamMx6B2RR/xq0rn1ASXdIjm/lnIWrH21SKSOMJOVelmBwgqMZmc2eIn2ESLuWIG nBcX8p+zHYldA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7A1B368FAF; Fri, 2 Jan 2026 18:20:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 2 Jan 2026 18:18:48 -0700 Message-ID: <20260103011908.149445-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103011908.149445-1-sjg@u-boot.org> References: <20260103011908.149445-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YUELRGBBKNCTT3WP65ZVI2H7RQ4EW6NR X-Message-ID-Hash: YUELRGBBKNCTT3WP65ZVI2H7RQ4EW6NR 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/24] test: malloc: Account for mcheck overhead in the large test 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 The malloc_very_large() test fails when mcheck is enabled with large CONFIG_MCHECK_CALLER_LEN because the 64K margin does not account for the per-allocation overhead (header + canaries). Use a larger margin (256K) when mcheck is enabled to ensure the test passes regardless of the mcheck caller length setting. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/common/malloc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/common/malloc.c b/test/common/malloc.c index 9fdc1789645..436aac503be 100644 --- a/test/common/malloc.c +++ b/test/common/malloc.c @@ -535,11 +535,21 @@ COMMON_TEST(common_test_mallinfo, 0); /* Test allocating a very large size */ static int common_test_malloc_very_large(struct unit_test_state *uts) { - size_t size, before; + size_t size, before, margin; void *ptr; before = get_alloced_size(); - size = TOTAL_MALLOC_LEN - before - SZ_64K; + + /* + * When mcheck is enabled, it adds overhead per allocation (header + + * canaries). With large CONFIG_MCHECK_CALLER_LEN, this can be + * significant. Use a larger margin to account for mcheck overhead. + */ + if (CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION)) + margin = SZ_256K; + else + margin = SZ_64K; + size = TOTAL_MALLOC_LEN - before - margin; ptr = malloc(size); ut_assertnonnull(ptr);