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=-2.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,UNWANTED_LANGUAGE_BODY 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 219D31F8C6 for ; Wed, 11 Aug 2021 07:42:42 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36709382CC1F for ; Wed, 11 Aug 2021 07:42:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36709382CC1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628667761; bh=MbeXe5k76S0w4811VL45ALbUcDbJZJu1hMvGh//DELg=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=owVkjeeFo94BzGw9jDUJeC1bjeeg6guuxNlmnlvbubpH6q76DKoOQ0XcgWBvLEOx3 AoPw7uS8ewdWp+7spMnCN4vVOKWP7ZoAtp9EDxSWmu6JJO5WOJWlKUnuvjsFWHLvl9 AJ4UMoU1fYvDo7rlHmEzMkHGi7CXcukcpPMdGjvk= Received: from camel.birch.relay.mailchannels.net (camel.birch.relay.mailchannels.net [23.83.209.29]) by sourceware.org (Postfix) with ESMTPS id CE11B3971C11 for ; Wed, 11 Aug 2021 07:41:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE11B3971C11 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 F24C7121FA6 for ; Wed, 11 Aug 2021 07:41:51 +0000 (UTC) Received: from pdx1-sub0-mail-a42.g.dreamhost.com (100-96-16-227.trex.outbound.svc.cluster.local [100.96.16.227]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3A7AB1225EC for ; Wed, 11 Aug 2021 07:41:51 +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.227 (trex/6.3.3); Wed, 11 Aug 2021 07:41:51 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Arch-Eyes: 36fcc9534dd18edb_1628667711464_2534201450 X-MC-Loop-Signature: 1628667711464:2085953382 X-MC-Ingress-Time: 1628667711463 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 E837D897EC for ; Wed, 11 Aug 2021 00:41:50 -0700 (PDT) Received: from [192.168.1.159] (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-a42.g.dreamhost.com (Postfix) with ESMTPSA id 168C87EED5 for ; Wed, 11 Aug 2021 00:41:49 -0700 (PDT) Subject: [PING][PATCH] mtrace: Use a static buffer for printing [BZ #25947] To: libc-alpha@sourceware.org References: <20210722132430.1945153-1-siddhesh@sourceware.org> X-DH-BACKEND: pdx1-sub0-mail-a42 Message-ID: <1f82d350-b81d-9b72-4456-3c495d516572@sourceware.org> Date: Wed, 11 Aug 2021 13:11:44 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210722132430.1945153-1-siddhesh@sourceware.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Ping! On 7/22/21 6:54 PM, Siddhesh Poyarekar via Libc-alpha wrote: > Use a static buffer for mtrace printing now that it no longer adds to > default libc footprint. > --- > malloc/mtrace-impl.c | 14 +++----------- > 1 file changed, 3 insertions(+), 11 deletions(-) > > diff --git a/malloc/mtrace-impl.c b/malloc/mtrace-impl.c > index 0e10ab7f60..83008ca18f 100644 > --- a/malloc/mtrace-impl.c > +++ b/malloc/mtrace-impl.c > @@ -34,11 +34,8 @@ > > #include > > -#define TRACE_BUFFER_SIZE 512 > - > static FILE *mallstream; > static const char mallenv[] = "MALLOC_TRACE"; > -static char *malloc_trace_buffer; > > static void > tr_where (const void *caller, Dl_info *info) > @@ -184,16 +181,13 @@ do_mtrace (void) > mallfile = secure_getenv (mallenv); > if (mallfile != NULL) > { > - char *mtb = malloc (TRACE_BUFFER_SIZE); > - if (mtb == NULL) > - return; > - > mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "wce"); > if (mallstream != NULL) > { > /* Be sure it doesn't malloc its buffer! */ > - malloc_trace_buffer = mtb; > - setvbuf (mallstream, malloc_trace_buffer, _IOFBF, TRACE_BUFFER_SIZE); > + static char tracebuf [512]; > + > + setvbuf (mallstream, tracebuf, _IOFBF, sizeof (tracebuf)); > fprintf (mallstream, "= Start\n"); > if (!added_atexit_handler) > { > @@ -203,8 +197,6 @@ do_mtrace (void) > } > __malloc_debug_enable (MALLOC_MTRACE_HOOK); > } > - else > - free (mtb); > } > } > >