From patchwork Mon Jul 5 17:08:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1500902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=h+bXSj0q; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GJXGm6gmWz9s5R for ; Tue, 6 Jul 2021 03:09:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 762A3386FC05 for ; Mon, 5 Jul 2021 17:09:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 762A3386FC05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625504955; bh=2SnB5CjCu5aPOdVjmn4j+xDgFS/EZeUq/aCtF8xab9g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=h+bXSj0qeBO3EwwNpJGhjcnoYw6fv9SV0LwSXYCszNSb6CO/XDBKaPerReY6D5fib 2mXE8a/0eTJZ90juHqyscrNHFZzj2FCRQ6jVfMDBPeboL6zCqkkdg432dS/96qumMe M7S1mBD4gW57CnBAwH4JcywjWkGk2V7lUxY3KwRA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from cross.elm.relay.mailchannels.net (cross.elm.relay.mailchannels.net [23.83.212.46]) by sourceware.org (Postfix) with ESMTPS id 948FE385803D for ; Mon, 5 Jul 2021 17:08:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 948FE385803D X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B168C322571; Mon, 5 Jul 2021 17:08:54 +0000 (UTC) Received: from pdx1-sub0-mail-a29.g.dreamhost.com (100-96-27-210.trex.outbound.svc.cluster.local [100.96.27.210]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0BD6F3223DC; Mon, 5 Jul 2021 17:08:54 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a29.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.27.210 (trex/6.3.3); Mon, 05 Jul 2021 17:08:54 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Whistle-Reign: 6cf06c7550850071_1625504934308_3281731087 X-MC-Loop-Signature: 1625504934308:2928737965 X-MC-Ingress-Time: 1625504934308 Received: from pdx1-sub0-mail-a29.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTP id C56887E4A5; Mon, 5 Jul 2021 10:08:53 -0700 (PDT) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a29.g.dreamhost.com (Postfix) with ESMTPSA id CABDA7E4B3; Mon, 5 Jul 2021 10:08:50 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a29 To: libc-alpha@sourceware.org Subject: [PATCH v5 0/8] malloc hooks removal Date: Mon, 5 Jul 2021 22:38:06 +0530 Message-Id: <20210705170814.4132997-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3486.9 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This patchset removes the malloc hooks __malloc_hook, __free_hook, __realloc_hook and __memalign_hook from the API and leaves compatibility symbols so that existing applications can continue to link to them. The reading and execution of the hooks has been moved to a DSO libc_malloc_debug.so, which can be preloaded for applications that need it. By default these hooks no longer have any effect in the library. Further, debugging features such as MALLOC_CHECK_, mcheck() and mtrace have been weaned away from these hooks and also moved to libc_malloc_debug.so. With this change, these features are only enabled when libc_malloc_debug.so is preloaded using LD_PRELOAD. Finally, the __morecore, __morecore_after_hook and __default_morecore hooks have also been moved to compat symbols and removed from the API. Existing applications will continue to link to them but they won't have any effect on malloc behaviour. Changes from v4: - Patchset has a different approach, starting with moving out hooks first to restrict all major malloc.c changes to the first patch - Renamed libmalloc_compathooks.so to libc_malloc_debug.so - Moved all debugging features into libc_malloc_debug.so - Made more documentation updates - Simplified __malloc_initialized variable use - Removed debugging tests on static variables since that is no longer supported Changes from v3: - Remove source file dependencies - Commit mcheck tests Changes from v2: - Move hooks dependencies to malloc.o{,sS} Changes from v1: - Added makefile dependencies for the new hooks files - Fixed memset call in calloc debugging hooks - Added the tr_break deprecation patch and mcheck test patch to this series Siddhesh Poyarekar (8): Move malloc hooks into a compat DSO mcheck: Wean away from malloc hooks Simplify __malloc_initialized mtrace: Wean away from malloc hooks glibc.malloc.check: Wean away from malloc hooks Remove malloc hooks Remove __after_morecore_hook Remove __morecore and __default_morecore Makeconfig | 2 +- NEWS | 21 ++ Rules | 9 +- catgets/Makefile | 4 +- elf/Makefile | 18 +- elf/tst-leaks1-static.c | 1 - iconvdata/Makefile | 3 +- include/malloc.h | 6 - include/mcheck.h | 4 - include/stdlib.h | 3 - intl/tst-gettext.sh | 1 + libio/Makefile | 12 +- localedata/Makefile | 3 +- malloc/Makefile | 44 ++- malloc/Versions | 9 + malloc/arena.c | 42 +-- malloc/hooks.c | 84 ++++- malloc/malloc-check.c | 86 +++-- malloc/{malloc-hooks.h => malloc-check.h} | 22 +- malloc/malloc-debug.c | 346 ++++++++++++++++++ malloc/malloc-internal.h | 5 + malloc/malloc.c | 135 ++----- malloc/malloc.h | 27 -- malloc/mcheck-impl.c | 406 +++++++++++++++++++++ malloc/mcheck.c | 396 ++------------------ malloc/morecore.c | 15 +- malloc/mtrace-impl.c | 224 ++++++++++++ malloc/mtrace.c | 313 +--------------- malloc/tst-compathooks-off.c | 145 ++++++++ malloc/tst-compathooks-on.c | 2 + malloc/tst-malloc-usable-static-tunables.c | 1 - malloc/tst-malloc-usable-static.c | 1 - malloc/tst-mtrace.sh | 1 + manual/memory.texi | 207 +---------- manual/tunables.texi | 4 +- misc/Makefile | 6 +- nptl/Makefile | 3 +- posix/Makefile | 40 +- resolv/Makefile | 9 +- stdio-common/Makefile | 15 +- sysdeps/pthread/Makefile | 3 +- 41 files changed, 1502 insertions(+), 1176 deletions(-) delete mode 100644 elf/tst-leaks1-static.c rename malloc/{malloc-hooks.h => malloc-check.h} (55%) create mode 100644 malloc/malloc-debug.c create mode 100644 malloc/mcheck-impl.c create mode 100644 malloc/mtrace-impl.c create mode 100644 malloc/tst-compathooks-off.c create mode 100644 malloc/tst-compathooks-on.c delete mode 100644 malloc/tst-malloc-usable-static-tunables.c delete mode 100644 malloc/tst-malloc-usable-static.c