From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 dcvr.yhbt.net (Postfix) with ESMTPS id 7E6FE1F8C6 for ; Fri, 2 Jul 2021 02:37:21 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AECE1397302C for ; Fri, 2 Jul 2021 02:37:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AECE1397302C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625193440; bh=UrJUS7aRq3GQRC19sD3f8NuZgonLLPj7zWhA517JGDg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=EJWAMaSrBVOa4m4W7cLj34S18GWmuNKHzIo6kojdys/oA0L4iW5hNjQZBPCKbiXlB p/AszbbL2AdjZS/0hZnE0cs1lu7bAF83mj0HDrykHYgh1UfcT1hpJ13F8IFR/rQqqU Oy+zWX75wikueFbZuz/WgwgEUE8CeUWt4R7Vfs1g= Received: from dormouse.elm.relay.mailchannels.net (dormouse.elm.relay.mailchannels.net [23.83.212.50]) by sourceware.org (Postfix) with ESMTPS id 8DDE93973026 for ; Fri, 2 Jul 2021 02:36:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DDE93973026 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 707C77E1210; Fri, 2 Jul 2021 02:36:12 +0000 (UTC) Received: from pdx1-sub0-mail-a42.g.dreamhost.com (100-96-16-86.trex.outbound.svc.cluster.local [100.96.16.86]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D61F97E1951; Fri, 2 Jul 2021 02:36:11 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a42.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.16.86 (trex/6.3.3); Fri, 02 Jul 2021 02:36:12 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Whispering-Lettuce: 6655c01064e0dd3c_1625193372141_432468749 X-MC-Loop-Signature: 1625193372141:2965684814 X-MC-Ingress-Time: 1625193372141 Received: from pdx1-sub0-mail-a42.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a42.g.dreamhost.com (Postfix) with ESMTP id 7F702897E3; Fri, 2 Jul 2021 02:36:10 +0000 (UTC) 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-a42.g.dreamhost.com (Postfix) with ESMTPSA id 096F8897E6; Fri, 2 Jul 2021 02:36:05 +0000 (UTC) X-DH-BACKEND: pdx1-sub0-mail-a42 To: libc-alpha@sourceware.org Subject: [PATCH v3 01/10] mtrace: Deprecate mallwatch and tr_break Date: Fri, 2 Jul 2021 08:05:37 +0530 Message-Id: <20210702023546.3081774-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702023546.3081774-1-siddhesh@sourceware.org> References: <20210702023546.3081774-1-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: , From: Siddhesh Poyarekar via Libc-alpha Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" The variable and function pair appear to provide a way for users to set conditional breakpoints in mtrace when a specific address is returned by the allocator. This can be achieved by using conditional breakpoints in gdb so it is redundant. There is no documentation of this interface in the manual either, so it appears to have been a hack that got added to debug malloc. Deprecate these symbols and do not call tr_break anymore. Reviewed-by: DJ Delorie --- NEWS | 4 ++++ malloc/mtrace.c | 57 +++++++++++++++++-------------------------------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/NEWS b/NEWS index 60933bd975..8e72946c3f 100644 --- a/NEWS +++ b/NEWS @@ -93,6 +93,10 @@ Deprecated and removed features, and other changes aff= ecting compatibility: package managers that delete removed files late during the package upgrade or downgrade process. =20 +* The symbols mallwatch and tr_break are now deprecated and no longer us= ed in + mtrace. Similar functionality can be achieved by using conditional + breakpoints within mtrace functions from within gdb. + Changes to build and runtime requirements: =20 * On Linux, the shm_open, sem_open, and related functions now expect the diff --git a/malloc/mtrace.c b/malloc/mtrace.c index b65b21a933..6c2c58b706 100644 --- a/malloc/mtrace.c +++ b/malloc/mtrace.c @@ -50,8 +50,25 @@ static char *malloc_trace_buffer; =20 __libc_lock_define_initialized (static, lock); =20 -/* Address to breakpoint on accesses to... */ +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34) +/* Compatibility symbols that were introduced to help break at allocatio= n sites + for specific memory allocations. This is unusable with ASLR, althoug= h gdb + may allow predictable allocation addresses. Even then, gdb has watch= point + and conditional breakpoint support which should provide the same + functionality without having this kludge. These symbols are preserve= d in + case some applications ended up linking against them but they don't a= ctually + do anything anymore; not that they did much before anyway. */ + void *mallwatch; +compat_symbol (libc, mallwatch, mallwatch, GLIBC_2_0); + +void +tr_break (void) +{ +} +compat_symbol (libc, tr_break, tr_break, GLIBC_2_0); +#endif + =20 /* Old hook values. */ static void (*tr_old_free_hook) (void *ptr, const void *); @@ -61,19 +78,6 @@ static void *(*tr_old_realloc_hook) (void *ptr, size_t= size, static void *(*tr_old_memalign_hook) (size_t __alignment, size_t __size, const void *); =20 -/* This function is called when the block being alloc'd, realloc'd, or - freed has an address matching the variable "mallwatch". In a debugge= r, - set "mallwatch" to the address of interest, then put a breakpoint on - tr_break. */ - -extern void tr_break (void) __THROW; -libc_hidden_proto (tr_break) -void -tr_break (void) -{ -} -libc_hidden_def (tr_break) - static void tr_where (const void *caller, Dl_info *info) { @@ -167,12 +171,6 @@ tr_freehook (void *ptr, const void *caller) tr_where (caller, info); /* Be sure to print it first. */ fprintf (mallstream, "- %p\n", ptr); - if (ptr =3D=3D mallwatch) - { - __libc_lock_unlock (lock); - tr_break (); - __libc_lock_lock (lock); - } set_default_hooks (); if (tr_old_free_hook !=3D NULL) (*tr_old_free_hook)(ptr, caller); @@ -203,9 +201,6 @@ tr_mallochook (size_t size, const void *caller) =20 __libc_lock_unlock (lock); =20 - if (hdr =3D=3D mallwatch) - tr_break (); - return hdr; } =20 @@ -214,9 +209,6 @@ tr_reallochook (void *ptr, size_t size, const void *c= aller) { void *hdr; =20 - if (ptr =3D=3D mallwatch) - tr_break (); - Dl_info mem; Dl_info *info =3D lock_and_info (caller, &mem); =20 @@ -247,9 +239,6 @@ tr_reallochook (void *ptr, size_t size, const void *c= aller) =20 __libc_lock_unlock (lock); =20 - if (hdr =3D=3D mallwatch) - tr_break (); - return hdr; } =20 @@ -274,9 +263,6 @@ tr_memalignhook (size_t alignment, size_t size, const= void *caller) =20 __libc_lock_unlock (lock); =20 - if (hdr =3D=3D mallwatch) - tr_break (); - return hdr; } =20 @@ -296,10 +282,7 @@ release_libc_mem (void) #endif =20 =20 -/* We enable tracing if either the environment variable MALLOC_TRACE - is set, or if the variable mallwatch has been patched to an address - that the debugging user wants us to stop on. When patching mallwatch= , - don't forget to set a breakpoint on tr_break! */ +/* We enable tracing if the environment variable MALLOC_TRACE is set. *= / =20 void mtrace (void) @@ -321,7 +304,7 @@ mtrace (void) #else mallfile =3D getenv (mallenv); #endif - if (mallfile !=3D NULL || mallwatch !=3D NULL) + if (mallfile !=3D NULL) { char *mtb =3D malloc (TRACE_BUFFER_SIZE); if (mtb =3D=3D NULL) --=20 2.31.1