From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from crocodile.elm.relay.mailchannels.net (crocodile.elm.relay.mailchannels.net [23.83.212.45]) by sourceware.org (Postfix) with ESMTPS id 789BE3858D28 for ; Thu, 21 Jul 2022 11:44:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 789BE3858D28 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 DF6EC5A221F; Thu, 21 Jul 2022 11:44:11 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D346F5A21B3; Thu, 21 Jul 2022 11:44:10 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1658403851; a=rsa-sha256; cv=none; b=blgWKRbs568rmSFa8QTnSVVJeBezQ8PohCg3M86yJ+ltBNPdaAFqzT3d0BKMkx8treSl9+ 29QfzQLtKxVBkJzTsTNWZpyEhew5EjeG/aNCAWTOmd5CDmU8J7I8/zuQ4YsLkqn1yTGDVi Rp1Z5amII5Ndm4vMU5ZAhApt/+5W/DrPyNp2wmFIEO0dHe8YS7lDrByFDAbY565QENy9D5 ZijK5sM6qpCBHMmqTNhL5FxYwomALrkh695t8sQqqDhZEd+RfLSY4R04uUkY+CoT35sM2k vQmtiTTRRYat/BiKr46c90P0ZVExToYn2IvMnu64uYZ+5ZKbCvBIJa/Z0O3Q1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1658403851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u4tEcPqIkCltbL9adcbu8UsED3u19rmOOzZTfI7syJQ=; b=V0S6wtpHKWXysWRW00h0nLmL8d/SWDtYxAktJMVbRQGnltd4bo5cCfuAmr2TMjhSkJC96u bXwYX5AYyi1xMts9/8phnOCwQwHP+RRuARDm6g57jJEDNMXvuS9GTNVVA36OFxEDVE6QWF 4z24AdMNHb39qCEK4jnFNrzT3yT2W62DRPzHa5sZvOb/g5s/FyEEPNjg99UHTB9rwsMkWc EsGHrpIZw9y6JN66I15VXNSwC5XFNoQfqh9E7smn9q9hw/78/yui05zoUS7GcB2+wqABMg SwEbI0tC83LUUlyrXl6Oq+yqaIjMyhEeQaZUYPxNMIxGp3uNPs4FGAHHz91f3A== ARC-Authentication-Results: i=1; rspamd-689699966c-8wn65; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Lettuce-Quick: 05ce7ecf15908150_1658403851660_1691770348 X-MC-Loop-Signature: 1658403851660:3007537746 X-MC-Ingress-Time: 1658403851660 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.242.215 (trex/6.7.1); Thu, 21 Jul 2022 11:44:11 +0000 Received: from [192.168.2.151] (bras-base-bmtnon1328w-grc-12-174-91-14-188.dsl.bell.ca [174.91.14.188]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4LpW1X1fbczB3; Thu, 21 Jul 2022 04:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1658403840; bh=u4tEcPqIkCltbL9adcbu8UsED3u19rmOOzZTfI7syJQ=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=HrVb9+jQMyIGMCk/u7hcDgo5fXPo2OttC+rJgKESvx0jQd5FRSwUg9ilxQ2SN/kUk f5yzHg9eqWSt8spQWLzpcef3UohR6F+03DsRX7q6MTRffmyGGr7ar3T9Tyl0yYyXDn 6lGRBGrGrSI1kBYhOSlWaTqUNiRfp48Dy0zaoythd1NK/T5229GIoZPYmrXYmJdcme +P1IQ5eWU/DvPFdvkQG88QRedBYmZMM83bRS65MnfTrfn9Ty1sCvV0sfOGk4vJViZk LbBNv0bYM2Eq3Og3VTf3qdKA4maiB+/61R1felsq2QjUmQqhOqhmMnjzZI+VWK/xdl vQe9M2Tyg6Owg== Message-ID: Date: Thu, 21 Jul 2022 07:43:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] malloc: Simplify implementation of __malloc_assert Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org References: <87a6924uvf.fsf@oldenburg.str.redhat.com> From: Siddhesh Poyarekar In-Reply-To: <87a6924uvf.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3038.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2022 11:44:17 -0000 On 2022-07-21 06:34, Florian Weimer via Libc-alpha wrote: > It is prudent not to run too much code after detecting heap > corruption, and __fxprintf is really complex. The line number > and file name do not carry much information, so it is not included > in the error message. (__libc_message only supports %s formatting.) > The function name and assertion should provide some context. > > Tested on i686-linux-gnu and x86_64-linux-gnu. Also emulated the > __libc_message call using GDB, and it produced the expected output. > > Thanks, > Florian > --- LGTM. Reviewed-by: Siddhesh Poyarekar > malloc/malloc.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/malloc/malloc.c b/malloc/malloc.c > index 12908b8f97..bd3c76ed31 100644 > --- a/malloc/malloc.c > +++ b/malloc/malloc.c > @@ -292,19 +292,14 @@ > # define __assert_fail(assertion, file, line, function) \ > __malloc_assert(assertion, file, line, function) > > -extern const char *__progname; > - > -static void > +_Noreturn static void > __malloc_assert (const char *assertion, const char *file, unsigned int line, > const char *function) > { > - (void) __fxprintf (NULL, "%s%s%s:%u: %s%sAssertion `%s' failed.\n", > - __progname, __progname[0] ? ": " : "", > - file, line, > - function ? function : "", function ? ": " : "", > - assertion); > - fflush (stderr); > - abort (); > + __libc_message (do_abort, "\ > +Fatal glibc error: malloc assertion failure in %s: %s\n", > + function, assertion); > + __builtin_unreachable (); > } > #endif > #endif >