From patchwork Wed Apr 2 12:09:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 109671 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7130E3857C6E for ; Wed, 2 Apr 2025 12:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7130E3857C6E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=qQo7N5jN; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=qQo7N5jN X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazlp170120003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c200::3]) by sourceware.org (Postfix) with ESMTPS id 6E6D33858420 for ; Wed, 2 Apr 2025 12:10:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E6D33858420 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6E6D33858420 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c200::3 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1743595833; cv=pass; b=cP00/boves6TzzAK13v47/GZWrPkYDvQDJ+UnGwHfppkjShaQrAa9TDIGGNd+Qq5+OJ6Z58Sf926PVf1+rr3fpxJTORFYot+gbxZXKlNWdmcbRVTwypPmR+9SkWONQxkcNZU7j/kmBZYd8NahgCqanh2BszlHVrJslFR/QYOaI4= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1743595833; c=relaxed/simple; bh=jxr6bQeBegFj3xQsMMfUc2xtdLd++NRgaSpEAco06d8=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=qqKOk+kqezpVuo5l+60f//3rmm2xggIDuEfrWrAKs5oPtJbg43gayjqhSfOqEmSLiYOWOj+w8MmgESgJkX9si3rftFhdNOsg/zol4nfmOG3NI0hLEoqtJEdyE1k70TgCTBKnvT8BCETr+rrSLd7ykFkT88Alb26nNURZlobF5gw= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E6D33858420 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=dNgFEMgAGvGV/1S+4osDa5K6hvYZuKGhpQOnqMlSc93BnPJaVeqGBn8ojnRZKtQEc9OrbTjK4yJxJm3+q3t99mLeeAlvIbCVpSxkBzkQufNXBIxZGyAUMR0lhV8BRALnxGyeZewAl3PrhOXI837nm9ja0tsqDJjsiZnTNzrsDgrfKIPdFGlUy9arpbRVTWJOzjcNZdWlW+7niitbpOYy4tjq4S84DhMOCizrj/SDfLCX5RpOTyXdwuOrDCJB/l8EV48Ek24yzwNmqPcMgDCqEkIQv3wyM5qRnIbeqRs/T9rs6zg63pWA/5Msba3tJgBMdfpiOuK6HW89tl2VUkhKlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qaZUbEIT7f/3BIb1S/FhuzZ3IgjG+pbBolEq3QHi6rs=; b=pWxqnWW3pLqncvbub6/i7v4aYR4KG0XtMyrmpIZhL11EJRnFBu/gz18FjYsRv9f4NYmA8wTLYF+JMHYp0M8l/KHNjY4EarCV0ZWW0xeeh7QrwKfe9HxcuLn2rwAmvi1CGhzqqHTZEvGtidioxVYsJL3+keJ3zOSsbNcj6K07OQOpc1xZPJBaKNxt5OkLKs9P/WD8BxGjGrLOnLcj6vrs21yLh+tjV2IExgM8dvmdf1VO0mkhtQ+Ej9CKAK0VFDF2nrsGjo6KkfVtESeGXkgYKYoYs3Q/MX+/rMWApUKCW1kslMP9EHbSxyNkRmxBaCBA8oURHRYchjhycyNNKxboQQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=fail (sender ip is 4.158.2.129) smtp.rcpttodomain=redhat.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qaZUbEIT7f/3BIb1S/FhuzZ3IgjG+pbBolEq3QHi6rs=; b=qQo7N5jNs1rgUAoiqTLWXy+jatcrLy2qnbSruw5bN6JHviPsNljJj57IrADNDuE2GXA3VSV+aNQGhWKD+E8HW8Xodr+cVmUStk+l1Bpp6iZjhqPEFs+Hm1zPL7NObc92jBsBpAIJ9oprUJa02IzKqsSnxfUZ7dY8/B1ismtBXuE= Received: from DU2PR04CA0307.eurprd04.prod.outlook.com (2603:10a6:10:2b5::12) by PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.52; Wed, 2 Apr 2025 12:10:30 +0000 Received: from DU6PEPF0000A7DF.eurprd02.prod.outlook.com (2603:10a6:10:2b5:cafe::55) by DU2PR04CA0307.outlook.office365.com (2603:10a6:10:2b5::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8583.41 via Frontend Transport; Wed, 2 Apr 2025 12:10:30 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DU6PEPF0000A7DF.mail.protection.outlook.com (10.167.8.36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Wed, 2 Apr 2025 12:10:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dN7ucNyK6+DOyNxulTftN7rgd0BjxR4ABkKd5ZSl6Fo+k+32F1UocS2eI3W5MFvXl4j0+tKYojx90Y9zzN+3fONWFPfUfVOZybmcWX71JPhF5R3vXJ72X3kR0GuPsGGGREWOvrMRx/1AjgU9AAFMgjDJETn1+Sg1mB3aTQh9pfKQuPIRPKgQPXTEeD20732Gh2Hi1LdH5V+C6S+KHCZ4s7ROHzvWzFa5T6KVAX7RbKb2+RfOcE8MmXU4EHSPGFwDVeqtSimDKPn9Mp80mDhG4g8TfwoZk/Rp2B3mZNxxvBXwKQSC+aWGBxoiN59pfnwQD8W1yC3ncnusP2zQSaNSWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qaZUbEIT7f/3BIb1S/FhuzZ3IgjG+pbBolEq3QHi6rs=; b=iJYxj7OiydScqP5L4gOxkhFDp3VC5eomDZrBiyKlLHwgzecDyvSCEQkmsfJLVssOMM384J0HOLyc2s525KNy0s/NproknIPwGQ1EukEWJUxRGcqd4BMOCK7q6elUuZgPyIFTFkARlIB3p7nsjjZGUYrwVL4raFlHoeOIgWRfyrvKyU/AUk3YNkOas4wxHxCVHGZzon1Bc/pcbbATHWIE4VIBHEyB4bAj1GWqa42bZ7LqvPP8RuxinFByxcpaJxHHsRzXPGHl0etagNWTtl0DYRM8hCdyEZXQpXHfuhZdlyz1sExP7df88kQdWhCaIYIwRISsmXf19tm8kcDNplgnQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qaZUbEIT7f/3BIb1S/FhuzZ3IgjG+pbBolEq3QHi6rs=; b=qQo7N5jNs1rgUAoiqTLWXy+jatcrLy2qnbSruw5bN6JHviPsNljJj57IrADNDuE2GXA3VSV+aNQGhWKD+E8HW8Xodr+cVmUStk+l1Bpp6iZjhqPEFs+Hm1zPL7NObc92jBsBpAIJ9oprUJa02IzKqsSnxfUZ7dY8/B1ismtBXuE= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by DB9PR08MB6505.eurprd08.prod.outlook.com (2603:10a6:10:23e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.54; Wed, 2 Apr 2025 12:09:54 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::b366:6358:236e:352d]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::b366:6358:236e:352d%4]) with mapi id 15.20.8534.043; Wed, 2 Apr 2025 12:09:54 +0000 From: Wilco Dijkstra To: Florian Weimer CC: 'GNU C Library' Subject: [PATCH v2] malloc: Improve malloc initialization Thread-Topic: [PATCH v2] malloc: Improve malloc initialization Thread-Index: AQHbo8gkLrp305qc9kmNU4pG0T+khw== Date: Wed, 2 Apr 2025 12:09:54 +0000 Message-ID: References: <87iknp9t7o.fsf@oldenburg.str.redhat.com> In-Reply-To: <87iknp9t7o.fsf@oldenburg.str.redhat.com> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|DB9PR08MB6505:EE_|DU6PEPF0000A7DF:EE_|PR3PR08MB5753:EE_ X-MS-Office365-Filtering-Correlation-Id: b7062e63-2492-45de-b0f6-08dd71df5c94 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; X-Microsoft-Antispam-Message-Info-Original: =?iso-8859-1?q?MgvJZAKY8TdGrsDgp?= =?iso-8859-1?q?rIXCjIQBUgIozQ8G8ULYnm8jkp9V7JoXiNZlxxZyi3w7zQQ4uz0q169DVtqd?= =?iso-8859-1?q?yp9VmxqvDkMzZnr5VgwfCQ3RvTRqvCkLzd/1dwNqrIhF2iZrBpky+OAu4xRn?= =?iso-8859-1?q?rwDvyIJBD8cuTGZV3xt34E7tXBfCWOPP7+s7gwakc3iCR2pRCTKCQVpvluqG?= =?iso-8859-1?q?oO82ZdDX8nJTAWx4GSNshbzwL5CQZwpUyUc1Mmw1iJSK0uuzzbRF0zj1H8Nx?= =?iso-8859-1?q?IHnoRQAb/4pZyNeFaQPJ32yTWp7B2WkXYOQmFsTslzHGuFiBwrgEoEBrtXdB?= =?iso-8859-1?q?Q4h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wy9qZojNfZ1z5oQ0m0ApQ1MSOCXE6ZsYuwEQLD?= =?iso-8859-1?q?fWQi4lVPhMSKDmzVFks5S3JmB/Zf8SiOUFgo1IqHQA44wotMHGvwXYFWHWpB?= =?iso-8859-1?q?hrNu+kiW6JtiHgEBLVLAxHVuYFoeoW9u7w2jquTLpCdJvZTcxPU7j1PEGFHA?= =?iso-8859-1?q?qVdKXhNbFh+QVvDqoeYXhZQVdyZ82ccsCBw4l1ZXQQloTTLH+Bhthk7Q7WWc?= =?iso-8859-1?q?J0FZWFwtNLnHRC/qk2zQax9TAvBxWRwTc/uzjJpUoD7zjrgQloYWhFWBd6FA?= =?iso-8859-1?q?erjCA9RuNbjYbFDXWdDQVxQf3yNzp4hzn8BFg=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8982.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6505 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000A7DF.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0e8c7f63-f221-43db-9018-08dd71df4775 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|82310400026|36860700013|376014|1800799024|14060799003; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?pLU2H0RlyvwdjukAJKqW+344qB?= =?iso-8859-1?q?9o/Q8yUbKzSsdSnkV4XlYD9AdPiJafCs5S15X5iwM5QB+mL/pOj+N1p64oWP?= =?iso-8859-1?q?M1s23Bwk5o3xYqtmGIcyfsbXC+b1RlWWn5YroKieyoSGT74pRCWrq+sWvBHO?= =?iso-8859-1?q?Q01T0QojS8eGZcpVqL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m+Q2OV30VVIqQArsz?= =?iso-8859-1?q?ZqOu7I742NSqv9unHWo6m0Y3444QAymONq+T8NwFPkmc5gs38ytAOo/+QGEr?= =?iso-8859-1?q?n/3bk1sHjQafNrpNLEwTKpfx0HLgM97mKKSMo1Vt/5fSFyqCqhp57kg7dHRS?= =?iso-8859-1?q?3b3WYGI1cVFbFs6CTFFUwKh1r1eYDNRtGWTC0NRQ07niH2+Yo/HJlBa96tTj?= =?iso-8859-1?q?fRDJHfML+S4YF5T+0fgATiUS+BIGHQFbrljYUMS7WalqJauPT7dnPt9DNrxk?= =?iso-8859-1?q?TAoTPK0CsqheqXye+HEW17gcjgXUQGMJ9V6AO3JLGY9RDZcl78AM2VPkMtZw?= =?iso-8859-1?q?5IC1qT2WIgCsW7PGyxO8vRmbIoEgyXdTDDY3akyx2ecGVSAavwdxGwbpL423?= =?iso-8859-1?q?K1e9EDAwJesB74NweSTPd3AQzsiCLZ2hu+NNZXpl8c/JheXCc9mYzpQ0seuc?= =?iso-8859-1?q?bveIuknhMsmSojDxY0gkHR/zGq9wCNpG3YI+6rjZeQjz2vcTmyyNXAk+X0hu?= =?iso-8859-1?q?Sghh7CPhGi?= X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(35042699022)(82310400026)(36860700013)(376014)(1800799024)(14060799003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2025 12:10:30.0903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7062e63-2492-45de-b0f6-08dd71df5c94 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF0000A7DF.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Hi Florian, > I think we should document the invariant that tache_init is called as > part of pthread_create, before the new thread starts running.  This way, > ptmalloc_init does not need to be thread-safe.  I think it's still the > case after this patch becaue MAYBE_INIT_TCACHE is called unconditionally > early and does not depend on the allocation size.  (Not sure why this is > a macro and not a function.)  I'd suggest comments on ptmalloc_init and > MAYBE_INIT_TCACHE that reference each other, and one of them should > describe the expected sequence of events.  Maybe also put a comment on > MAYBE_INIT_TCACHE in __libc_malloc2? I think it works out fine as long as there is at least one call to malloc before a new thread is started. The existing initialization already relies on this - I just made it explicit that tcache_init relies on ptmalloc_init having been called first (if you call tcache_init first, it would crash in the medium bin code). I haven't decided on what to do with MAYBE_INIT_TCACHE, but in principle we could initialize tcache from arena_get (as thread_arena == NULL for new threads). This would remove all tcache initialization checks from hot paths. > Regarding doing this initialization early and unconditionally: This > could well work today, especially if we do it early via > __libc_early_init for dynamically linked builds (so that malloc is > available in PREINIT and LD_PRELOAD objects). I tried it and it does work indeed - it's slightly tricky due to the complexity of malloc-debug containing an almost complete copy of malloc while also wanting to use the libc one at the same time! > For static builds, additional work will be required, or we could keep > the current scheme for that case.  (I think in general, malloc can be > called before ELF constructors have run in the static case.) The patch below passes all malloc tests (not sure whether it tests static binaries as well as dynamic though). I can add some assertions to enforce we never start allocating blocks before malloc is initialized. > If we ever start allocating during initialization (I expect us to > reserve address space for all possible struct malloc_state objects, for > example) and we want to avoid that for interposed mallocs, then I think > a lazy scheme is the only feasible way.  We can't call into the > interposed malloc from __libc_early_init because its ELF constructor has > not run yet. Hmm, it does appear to "just work"... Are you saying for dynamic case we should call __libc_malloc (-1) to initialize our own malloc (without knowing whether it is interposed or not), and malloc (-1) for static? Cheers, Wilco v2: Initialize malloc from __libc_early_init Move malloc initialization to __libc_early_init. Since malloc/calloc/realloc/free are the minimal interposable functions, use a huge out of range malloc for initialization. The related malloc-debug initialization does the same. All other initialization checks can now be removed. Tcache_init() needs an initialization check since it may be called unconditionally from malloc(). The tst-compathooks-on.c test needs updating to avoid counting the malloc/free() calls from __libc_early_init (when interposed only the interposed malloc is initialized). diff --git a/elf/libc_early_init.c b/elf/libc_early_init.c index 07202317534a4edbd2202c6e45770094cadb67f6..6ab14fb239a02d8da356a1fc5bdb307aabf35705 100644 --- a/elf/libc_early_init.c +++ b/elf/libc_early_init.c @@ -29,9 +29,19 @@ _Bool __libc_initial; #endif +static void __attribute_noinline__ +myfree (void *p) +{ + free (p); +} + void __libc_early_init (_Bool initial) { + /* Initialize malloc using an out-of-range malloc. */ + volatile size_t size = -1; + myfree (malloc (size)); + /* Initialize ctype data. */ __ctype_init (); diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c index d208aa32a3c650cbce88f7bc04cc85969db56dcf..18ee300990bfa7d6e2a1ed46d663e4bc3773e073 100644 --- a/malloc/malloc-debug.c +++ b/malloc/malloc-debug.c @@ -116,7 +116,7 @@ generic_hook_ini (void) if (!initialize_malloc_check ()) /* The compiler does not know that these functions are allocators, so it will not try to optimize it away. */ - __libc_free (__libc_malloc (0)); + __libc_free (__libc_malloc (-1)); #if SHLIB_COMPAT (libc_malloc_debug, GLIBC_2_0, GLIBC_2_24) void (*hook) (void) = __malloc_initialize_hook; diff --git a/malloc/malloc.c b/malloc/malloc.c index a0bc733482532ce34684d0357cb9076b03ac8a52..986e6211a86bfaf7b0309b138a067f16e92d1bbd 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3316,6 +3316,10 @@ tcache_init(void) if (tcache_shutting_down) return; + /* Ensure malloc is initialized before tcache. */ + if (!__malloc_initialized) + ptmalloc_init (); + arena_get (ar_ptr, bytes); victim = _int_malloc (ar_ptr, bytes); if (!victim && ar_ptr != NULL) @@ -3390,9 +3394,6 @@ __libc_malloc2 (size_t bytes) mstate ar_ptr; void *victim; - if (!__malloc_initialized) - ptmalloc_init (); - MAYBE_INIT_TCACHE (); if (SINGLE_THREAD_P) @@ -3495,9 +3496,6 @@ __libc_realloc (void *oldmem, size_t bytes) void *newp; /* chunk to return */ - if (!__malloc_initialized) - ptmalloc_init (); - #if REALLOC_ZERO_BYTES_FREES if (bytes == 0 && oldmem != NULL) { @@ -3623,9 +3621,6 @@ libc_hidden_def (__libc_realloc) void * __libc_memalign (size_t alignment, size_t bytes) { - if (!__malloc_initialized) - ptmalloc_init (); - void *address = RETURN_ADDRESS (0); return _mid_memalign (alignment, bytes, address); } @@ -3636,9 +3631,6 @@ void * weak_function aligned_alloc (size_t alignment, size_t bytes) { - if (!__malloc_initialized) - ptmalloc_init (); - /* Similar to memalign, but starting with ISO C17 the standard requires an error for alignments that are not supported by the implementation. Valid alignments for the current implementation @@ -3746,9 +3738,6 @@ _mid_memalign (size_t alignment, size_t bytes, void *address) void * __libc_valloc (size_t bytes) { - if (!__malloc_initialized) - ptmalloc_init (); - void *address = RETURN_ADDRESS (0); size_t pagesize = GLRO (dl_pagesize); return _mid_memalign (pagesize, bytes, address); @@ -3757,9 +3746,6 @@ __libc_valloc (size_t bytes) void * __libc_pvalloc (size_t bytes) { - if (!__malloc_initialized) - ptmalloc_init (); - void *address = RETURN_ADDRESS (0); size_t pagesize = GLRO (dl_pagesize); size_t rounded_bytes; @@ -3794,9 +3780,6 @@ __libc_calloc (size_t n, size_t elem_size) sz = bytes; - if (!__malloc_initialized) - ptmalloc_init (); - #if USE_TCACHE bool err = tcache_try_malloc (bytes, &mem); @@ -3943,6 +3926,9 @@ _int_malloc (mstate av, size_t bytes) if (nb == 0) { __set_errno (ENOMEM); + /* Special malloc initialization case. */ + if (!__malloc_initialized) + ptmalloc_init (); return NULL; } @@ -5277,9 +5263,6 @@ __malloc_trim (size_t s) { int result = 0; - if (!__malloc_initialized) - ptmalloc_init (); - mstate ar_ptr = &main_arena; do { @@ -5396,9 +5379,6 @@ __libc_mallinfo2 (void) struct mallinfo2 m; mstate ar_ptr; - if (!__malloc_initialized) - ptmalloc_init (); - memset (&m, 0, sizeof (m)); ar_ptr = &main_arena; do @@ -5447,8 +5427,6 @@ __malloc_stats (void) mstate ar_ptr; unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b; - if (!__malloc_initialized) - ptmalloc_init (); _IO_flockfile (stderr); int old_flags2 = stderr->_flags2; stderr->_flags2 |= _IO_FLAGS2_NOTCANCEL; @@ -5629,8 +5607,6 @@ __libc_mallopt (int param_number, int value) mstate av = &main_arena; int res = 1; - if (!__malloc_initialized) - ptmalloc_init (); __libc_lock_lock (av->mutex); LIBC_PROBE (memory_mallopt, 2, param_number, value); @@ -5852,9 +5828,6 @@ __posix_memalign (void **memptr, size_t alignment, size_t size) { void *mem; - if (!__malloc_initialized) - ptmalloc_init (); - /* Test whether the SIZE argument is valid. It must be a power of two multiple of sizeof (void *). */ if (alignment % sizeof (void *) != 0 @@ -5895,11 +5868,6 @@ __malloc_info (int options, FILE *fp) size_t total_aspace = 0; size_t total_aspace_mprotect = 0; - - - if (!__malloc_initialized) - ptmalloc_init (); - fputs ("\n", fp); /* Iterate over all arenas currently in use. */ diff --git a/malloc/tst-compathooks-off.c b/malloc/tst-compathooks-off.c index 82c47ebb6c182d46b031d4949c5bf5e60e5ef10b..45289a2024dc4edeb05239e12a11aaf13d53ab5c 100644 --- a/malloc/tst-compathooks-off.c +++ b/malloc/tst-compathooks-off.c @@ -110,6 +110,8 @@ DIAG_POP_NEEDS_COMMENT; static int do_test (void) { + hook_count = 0; + void *p; p = malloc (0); TEST_VERIFY_EXIT (p != NULL);