summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-08-03 11:41:53 +0200
committerFlorian Weimer <fweimer@redhat.com>2022-08-03 11:42:39 +0200
commitcca9684f2d7a74fc0b28bfb1859955e0e28d7b4b (patch)
treef07de8d03a36b0d91b7053a88af8d7818b0af20e /sysdeps/posix
parentfccadcdf5bed7ee67a6cef4714e0b477d6c8472c (diff)
downloadglibc-cca9684f2d7a74fc0b28bfb1859955e0e28d7b4b.tar.gz
glibc-cca9684f2d7a74fc0b28bfb1859955e0e28d7b4b.tar.xz
glibc-cca9684f2d7a74fc0b28bfb1859955e0e28d7b4b.zip
stdio: Clean up __libc_message after unconditional abort
Since commit ec2c1fcefb200c6cb7e09553f3c6af8815013d83 ("malloc:
Abort on heap corruption, without a backtrace [BZ #21754]"),
__libc_message always terminates the process.  Since commit
a289ea09ea843ced6e5277c2f2e63c357bc7f9a3 ("Do not print backtraces
on fatal glibc errors"), the backtrace facility has been removed.
Therefore, remove enum __libc_message_action and the action
argument of __libc_message, and mark __libc_message as _No_return.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/libc_fatal.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
index 2ee0010b8d..270238495d 100644
--- a/sysdeps/posix/libc_fatal.c
+++ b/sysdeps/posix/libc_fatal.c
@@ -54,7 +54,7 @@ struct str_list
 
 /* Abort with an error message.  */
 void
-__libc_message (enum __libc_message_action action, const char *fmt, ...)
+__libc_message (const char *fmt, ...)
 {
   va_list ap;
   int fd = -1;
@@ -123,36 +123,31 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...)
 
       WRITEV_FOR_FATAL (fd, iov, nlist, total);
 
-      if ((action & do_abort))
+      total = (total + 1 + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
+      struct abort_msg_s *buf = __mmap (NULL, total,
+					PROT_READ | PROT_WRITE,
+					MAP_ANON | MAP_PRIVATE, -1, 0);
+      if (__glibc_likely (buf != MAP_FAILED))
 	{
-	  total = ((total + 1 + GLRO(dl_pagesize) - 1)
-		   & ~(GLRO(dl_pagesize) - 1));
-	  struct abort_msg_s *buf = __mmap (NULL, total,
-					    PROT_READ | PROT_WRITE,
-					    MAP_ANON | MAP_PRIVATE, -1, 0);
-	  if (__glibc_likely (buf != MAP_FAILED))
-	    {
-	      buf->size = total;
-	      char *wp = buf->msg;
-	      for (int cnt = 0; cnt < nlist; ++cnt)
-		wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
-	      *wp = '\0';
-
-	      /* We have to free the old buffer since the application might
-		 catch the SIGABRT signal.  */
-	      struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg,
-							     buf);
-	      if (old != NULL)
-		__munmap (old, old->size);
-	    }
+	  buf->size = total;
+	  char *wp = buf->msg;
+	  for (int cnt = 0; cnt < nlist; ++cnt)
+	    wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
+	  *wp = '\0';
+
+	  /* We have to free the old buffer since the application might
+	     catch the SIGABRT signal.  */
+	  struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg,
+							 buf);
+	  if (old != NULL)
+	    __munmap (old, old->size);
 	}
     }
 
   va_end (ap);
 
-  if ((action & do_abort))
-    /* Kill the application.  */
-    abort ();
+  /* Kill the application.  */
+  abort ();
 }
 
 
@@ -161,6 +156,6 @@ __libc_fatal (const char *message)
 {
   /* The loop is added only to keep gcc happy.  */
   while (1)
-    __libc_message (do_abort, "%s", message);
+    __libc_message ("%s", message);
 }
 libc_hidden_def (__libc_fatal)