+2016-06-13 Florian Weimer <fweimer@redhat.com>
+
+ [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 <adhemerval.zanella@linaro.org>
* nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
#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)
pass++;
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);
}
else
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;
}