public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.35/master] malloc: Simplify implementation of __malloc_assert
Date: Thu, 21 Jul 2022 15:05:31 +0000 (GMT)	[thread overview]
Message-ID: <20220721150531.B2582385843D@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0e5b239f45992e4b54c6f946ecb0c410afc8bb08

commit 0e5b239f45992e4b54c6f946ecb0c410afc8bb08
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jul 21 12:12:08 2022 +0200

    malloc: Simplify implementation of __malloc_assert
    
    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.
    
    Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
    (cherry picked from commit ac8047cdf326504f652f7db97ec96c0e0cee052f)

Diff:
---
 malloc/malloc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 1a1ac1d8f0..fe9cb9b800 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


                 reply	other threads:[~2022-07-21 15:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220721150531.B2582385843D@sourceware.org \
    --to=fw@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).