From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cornsilk.ash.relay.mailchannels.net (cornsilk.ash.relay.mailchannels.net [23.83.222.40]) by sourceware.org (Postfix) with ESMTPS id DF93A3950C17 for ; Mon, 28 Jun 2021 08:40:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF93A3950C17 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org 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 4B31D541726 for ; Mon, 28 Jun 2021 08:40:15 +0000 (UTC) Received: from pdx1-sub0-mail-a39.g.dreamhost.com (100-96-133-119.trex.outbound.svc.cluster.local [100.96.133.119]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id CB927542030 for ; Mon, 28 Jun 2021 08:40:14 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a39.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.133.119 (trex/6.3.3); Mon, 28 Jun 2021 08:40:15 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Imminent-Whistle: 1d3d0fbd7518876f_1624869615076_3616723843 X-MC-Loop-Signature: 1624869615076:2984408197 X-MC-Ingress-Time: 1624869615076 Received: from pdx1-sub0-mail-a39.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a39.g.dreamhost.com (Postfix) with ESMTP id 59CFF7F455 for ; Mon, 28 Jun 2021 01:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=subject:to :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=GiN5wN asM28odwxRVXxXrkhwvN4=; b=J4PbD+opR6VG0VIiVQ/77F+JEak8WRU7Gwfk+1 0ClIz5a8SFCXkA0QXF7+8EvEuhtIvSvrrkJMxnIl8ZVIn21PG5QY7FIw6tzA2KkQ IMFd7XNGpDH88PRj+wRzvJpG/2dUOaX6h3addsJfiT/B+IKFyV3Dv5gWTs+MSuBX vGQcY= Received: from [192.168.1.136] (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a39.g.dreamhost.com (Postfix) with ESMTPSA id 72AC87EE56 for ; Mon, 28 Jun 2021 01:40:12 -0700 (PDT) Subject: [PING][PATCH] mtrace: Deprecate mallwatch and tr_break To: libc-alpha@sourceware.org References: <20210623155514.3292784-1-siddhesh@sourceware.org> X-DH-BACKEND: pdx1-sub0-mail-a39 From: Siddhesh Poyarekar Message-ID: <9cb05991-1586-46c4-0e1c-8f9490117353@gotplt.org> Date: Mon, 28 Jun 2021 14:10:08 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210623155514.3292784-1-siddhesh@sourceware.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3037.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Mon, 28 Jun 2021 08:40:24 -0000 On 6/23/21 9:25 PM, Siddhesh Poyarekar via Libc-alpha wrote: > 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. > --- > NEWS | 4 ++++ > malloc/mtrace.c | 57 +++++++++++++++++-------------------------------- > 2 files changed, 24 insertions(+), 37 deletions(-) > > diff --git a/NEWS b/NEWS > index cadc40262f..536e80721a 100644 > --- a/NEWS > +++ b/NEWS > @@ -64,6 +64,10 @@ Deprecated and removed features, and other changes affecting compatibility: > * The function pthread_yield has been deprecated; programs should use > the equivalent standard function sched_yield instead. > > +* The symbols mallwatch and tr_break are now deprecated and no longer used in > + mtrace. Similar functionality can be achieved by using conditional > + breakpoints within mtrace functions from within gdb. > + > Changes to build and runtime requirements: > > * 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; > > __libc_lock_define_initialized (static, lock); > > -/* 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 allocation sites > + for specific memory allocations. This is unusable with ASLR, although gdb > + may allow predictable allocation addresses. Even then, gdb has watchpoint > + and conditional breakpoint support which should provide the same > + functionality without having this kludge. These symbols are preserved in > + case some applications ended up linking against them but they don't actually > + 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 > + > > /* 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 *); > > -/* This function is called when the block being alloc'd, realloc'd, or > - freed has an address matching the variable "mallwatch". In a debugger, > - 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 == mallwatch) > - { > - __libc_lock_unlock (lock); > - tr_break (); > - __libc_lock_lock (lock); > - } > set_default_hooks (); > if (tr_old_free_hook != NULL) > (*tr_old_free_hook)(ptr, caller); > @@ -203,9 +201,6 @@ tr_mallochook (size_t size, const void *caller) > > __libc_lock_unlock (lock); > > - if (hdr == mallwatch) > - tr_break (); > - > return hdr; > } > > @@ -214,9 +209,6 @@ tr_reallochook (void *ptr, size_t size, const void *caller) > { > void *hdr; > > - if (ptr == mallwatch) > - tr_break (); > - > Dl_info mem; > Dl_info *info = lock_and_info (caller, &mem); > > @@ -247,9 +239,6 @@ tr_reallochook (void *ptr, size_t size, const void *caller) > > __libc_lock_unlock (lock); > > - if (hdr == mallwatch) > - tr_break (); > - > return hdr; > } > > @@ -274,9 +263,6 @@ tr_memalignhook (size_t alignment, size_t size, const void *caller) > > __libc_lock_unlock (lock); > > - if (hdr == mallwatch) > - tr_break (); > - > return hdr; > } > > @@ -296,10 +282,7 @@ release_libc_mem (void) > #endif > > > -/* 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. */ > > void > mtrace (void) > @@ -321,7 +304,7 @@ mtrace (void) > #else > mallfile = getenv (mallenv); > #endif > - if (mallfile != NULL || mallwatch != NULL) > + if (mallfile != NULL) > { > char *mtb = malloc (TRACE_BUFFER_SIZE); > if (mtb == NULL) >