This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.23-470-g2c41b52

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  2c41b52901331f5c761015af786a3976e225d779 (commit)
      from  f5c77f78ec03363d5e550c4996deb75ee3f2e32a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------;a=commitdiff;h=2c41b52901331f5c761015af786a3976e225d779

commit 2c41b52901331f5c761015af786a3976e225d779
Author: Florian Weimer <>
Date:   Mon Jun 13 13:08:39 2016 +0200

    debug/tst-longjmp_chk2: Make signal handler more conservative [BZ #20248]
    Currently, printf needs more stack space than what is available with
    SIGSTKSZ.  This commit use the the write system call directly instead.
    Also use sig_atomic_t for the â??passâ?? variable (for general
    correctness), and restore signal handlers to their defaults, to avoid
    masking crashes.

diff --git a/ChangeLog b/ChangeLog
index 53ab8ca..7f8da5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-13  Florian Weimer  <>
+	[BZ #20248]
+	* debug/tst-longjmp_chk2.c (pass): Use volatile sig_atomic_t.
+	(write_message): New function.
+	(stackoverflow_handler): Call it instead of printf, to avoid
+	excessive stack usage by printf.
+	(do_test): Restore SIGSEGV, SIGBUS default handlers.
 2016-06-13  Adhemerval Zanella  <>
 	* nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
diff --git a/debug/tst-longjmp_chk2.c b/debug/tst-longjmp_chk2.c
index dae9ca0..243568c 100644
--- a/debug/tst-longjmp_chk2.c
+++ b/debug/tst-longjmp_chk2.c
@@ -6,15 +6,25 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <unistd.h>
 static jmp_buf mainloop;
 static sigset_t mainsigset;
-static int pass;
+static volatile sig_atomic_t pass;
+static void
+write_message (const char *message)
+  ssize_t unused __attribute__ ((unused));
+  for (int i = 0; i < pass; ++i)
+    unused = write (STDOUT_FILENO, " ", 1);
+  unused = write (STDOUT_FILENO, message, strlen (message));
 static void
 stackoverflow_handler (int sig)
@@ -25,11 +35,9 @@ stackoverflow_handler (int sig)
   assert (pass < 5);
   sigaltstack (NULL, &altstack);
-  /* Using printf is not really kosher in signal handlers but we know
-     it will work.  */
-  printf ("%*sin signal handler\n", pass, "");
+  write_message ("in signal handler\n");
   if (altstack.ss_flags & SS_ONSTACK)
-    printf ("%*son alternate stack\n", pass, "");
+    write_message ("on alternate stack\n");
   siglongjmp (mainloop, pass);
@@ -112,6 +120,11 @@ do_test (void)
     printf ("disabling alternate stack succeeded \n");
+  /* Restore the signal handlers, in case we trigger a crash after the
+     tests above.  */
+  signal (SIGBUS, SIG_DFL);
+  signal (SIGSEGV, SIG_DFL);
   return 0;


Summary of changes:
 ChangeLog                |    9 +++++++++
 debug/tst-longjmp_chk2.c |   23 ++++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)

GNU C Library master sources

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]