From 1fc4e011bb0d977b64385e5dff91620c42985bcf Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Wed, 4 Jul 2018 02:11:27 +0000
Subject: [PATCH 25/27] tests: check tracing of looping threads
* test/many_looping_threads.c: Remove.
* test/.gitignore: Remove many_looping_threads.
* test/Makefile (PROGS): Likewise.
(many_looping_threads): Remove.
* tests/looping_threads.c: New file.
* tests/looping_threads.test: New test.
* tests/.gitignore: Add looping_threads.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(looping_threads_LDADD): New variable.
(MISC_TESTS, XFAIL_TESTS): Add looping_threads.test.
Conflicts:
tests/Makefile.am
Skipped files (not present in the tarball):
test/.gitignore
test/Makefile
test/many_looping_threads.c
tests/.gitignore
Additional changes:
tests/Makefile.in (generated from tests/Makefile.am)
tests-m32/Makefile.in (generated from tests-m32/Makefile.am)
tests-m32/looping_threads.c (copy of tests/looping_threads.c)
tests-m32/looping_threads.test (copy of tests/looping_threads.test)
tests-mx32/Makefile.in (generated from tests-mx32/Makefile.am)
tests-mx32/looping_threads.c (copy of tests/looping_threads.c)
tests-mx32/looping_threads.test (copy of tests/looping_threads.test)
---
test/.gitignore | 1 -
test/Makefile | 5 +-
test/many_looping_threads.c | 49 ------------------
tests/.gitignore | 1 +
tests/Makefile.am | 6 ++-
tests/looping_threads.c | 121 ++++++++++++++++++++++++++++++++++++++++++++
tests/looping_threads.test | 38 ++++++++++++++
7 files changed, 166 insertions(+), 55 deletions(-)
delete mode 100644 test/many_looping_threads.c
create mode 100644 tests/looping_threads.c
create mode 100755 tests/looping_threads.test
Index: strace-4.24/tests/Makefile.am
===================================================================
--- strace-4.24.orig/tests/Makefile.am 2020-01-27 17:41:26.653586903 +0100
+++ strace-4.24/tests/Makefile.am 2020-01-27 20:17:51.315382082 +0100
@@ -108,6 +108,7 @@
ksysent \
list_sigaction_signum \
localtime \
+ looping_threads \
mmsg-silent \
mmsg_name-v \
msg_control-v \
@@ -172,6 +173,7 @@
fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
localtime_LDADD = $(clock_LIBS) $(LDADD)
+looping_threads_LDADD = -lpthread $(LDADD)
lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_Xabbrev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
@@ -304,6 +306,7 @@
kill_child.test \
ksysent.test \
localtime.test \
+ looping_threads.test \
opipe.test \
options-syntax.test \
pc.test \
@@ -347,7 +350,8 @@
XFAIL_TESTS_mx32 = $(STACKTRACE_TESTS)
XFAIL_TESTS_x86_64 = int_0x80.gen.test
XFAIL_TESTS_x32 = int_0x80.gen.test
-XFAIL_TESTS = $(XFAIL_TESTS_$(MPERS_NAME)) $(XFAIL_TESTS_$(ARCH))
+XFAIL_TESTS = $(XFAIL_TESTS_$(MPERS_NAME)) $(XFAIL_TESTS_$(ARCH)) \
+ looping_threads.test
TEST_LOG_COMPILER = env
AM_TEST_LOG_FLAGS = STRACE_ARCH=$(ARCH) STRACE_NATIVE_ARCH=$(NATIVE_ARCH) \
Index: strace-4.24/tests/looping_threads.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests/looping_threads.c 2020-01-27 17:41:26.671586776 +0100
@@ -0,0 +1,121 @@
+/*
+ * Check tracing of looping threads.
+ *
+ * Copyright (c) 2009-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static void *
+thread(void *arg)
+{
+ for (;;)
+ getuid();
+ return arg;
+}
+
+int
+main(int ac, const char *av[])
+{
+ assert(ac == 3);
+
+ int timeout = atoi(av[1]);
+ assert(timeout > 0);
+
+ int num_threads = atoi(av[2]);
+ assert(num_threads > 0);
+
+ /*
+ * Unblock all signals.
+ */
+ static sigset_t mask;
+ if (sigprocmask(SIG_SETMASK, &mask, NULL))
+ perror_msg_and_fail("sigprocmask");
+
+ /*
+ * Reset SIGALRM and SIGHUP signal handlers.
+ */
+ static const struct sigaction sa_def = { .sa_handler = SIG_DFL };
+ if (sigaction(SIGHUP, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGHUP");
+ if (sigaction(SIGALRM, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGALRM");
+
+ /*
+ * Create a new process group.
+ */
+ if (setpgid(0, 0))
+ perror_msg_and_fail("setpgid");
+
+ /*
+ * Set an alarm clock.
+ */
+ alarm(timeout);
+
+ /*
+ * When the main process terminates, the process group becomes orphaned.
+ * If any member of the orphaned process group is stopped, then
+ * a SIGHUP signal followed by a SIGCONT signal is sent to each process
+ * in the orphaned process group.
+ * Create a process in a stopped state to activate this behaviour.
+ */
+ const pid_t stopped = fork();
+ if (stopped < 0)
+ perror_msg_and_fail("fork");
+ if (!stopped) {
+ raise(SIGSTOP);
+ _exit(0);
+ }
+
+ /*
+ * Wait for the process to stop.
+ */
+ int status;
+ if (waitpid(stopped, &status, WUNTRACED) != stopped)
+ perror_msg_and_fail("waitpid WUNTRACED");
+ if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ error_msg_and_fail("waitpid WUNTRACED: "
+ "unexpected wait status %d", status);
+ /*
+ * Create all threads in a subprocess, this guarantees that
+ * their tracer will not be their parent.
+ */
+ pid_t pid = fork();
+ if (pid < 0)
+ perror_msg_and_fail("fork");
+ if (!pid) {
+ for (int i = 0; i < num_threads; i++) {
+ pthread_t t;
+ if ((errno = pthread_create(&t, NULL, thread, NULL))) {
+ if (EAGAIN == errno)
+ break;
+ perror_msg_and_fail("pthread_create #%d", i);
+ }
+ }
+
+ /* This terminates all threads created above. */
+ _exit(0);
+ }
+
+ if (waitpid(pid, &status, 0) != pid)
+ perror_msg_and_fail("waitpid");
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ error_msg_and_fail("waitpid: unexpected wait status %d",
+ status);
+
+ /*
+ * Make the process group orphaned.
+ */
+ return 0;
+}
Index: strace-4.24/tests/looping_threads.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests/looping_threads.test 2020-01-27 17:41:26.671586776 +0100
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Check tracing of looping threads.
+#
+# Copyright (c) 2009-2019 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+. "${srcdir=.}/PTRACE_SEIZE.sh"
+
+run_prog ../orphaned_process_group > /dev/null
+
+run_prog_skip_if_failed date +%s > /dev/null
+s0="$(date +%s)"
+
+check_prog nproc
+inc="$(nproc)"
+[ "$inc" -ge 1 ] || inc=1
+
+timeout_2="$(($TIMEOUT_DURATION/2))"
+timeout_8="$(($TIMEOUT_DURATION/8))"
+nproc=1
+
+run_prog "../$NAME" "$timeout_8" "$nproc"
+
+while :; do
+ run_strace -f -qq -enone -esignal=none "../$NAME" "$timeout_2" "$nproc"
+
+ s1="$(date +%s)"
+ [ "$(($s1-$s0))" -lt "$timeout_8" ] ||
+ break
+
+ nproc="$(($nproc+$inc))"
+done
+
+warn_ "$ME_: nproc=$nproc elapsed=$(($s1-$s0))"
Index: strace-4.24/tests-m32/looping_threads.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-m32/looping_threads.c 2020-01-27 17:41:26.671586776 +0100
@@ -0,0 +1,121 @@
+/*
+ * Check tracing of looping threads.
+ *
+ * Copyright (c) 2009-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static void *
+thread(void *arg)
+{
+ for (;;)
+ getuid();
+ return arg;
+}
+
+int
+main(int ac, const char *av[])
+{
+ assert(ac == 3);
+
+ int timeout = atoi(av[1]);
+ assert(timeout > 0);
+
+ int num_threads = atoi(av[2]);
+ assert(num_threads > 0);
+
+ /*
+ * Unblock all signals.
+ */
+ static sigset_t mask;
+ if (sigprocmask(SIG_SETMASK, &mask, NULL))
+ perror_msg_and_fail("sigprocmask");
+
+ /*
+ * Reset SIGALRM and SIGHUP signal handlers.
+ */
+ static const struct sigaction sa_def = { .sa_handler = SIG_DFL };
+ if (sigaction(SIGHUP, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGHUP");
+ if (sigaction(SIGALRM, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGALRM");
+
+ /*
+ * Create a new process group.
+ */
+ if (setpgid(0, 0))
+ perror_msg_and_fail("setpgid");
+
+ /*
+ * Set an alarm clock.
+ */
+ alarm(timeout);
+
+ /*
+ * When the main process terminates, the process group becomes orphaned.
+ * If any member of the orphaned process group is stopped, then
+ * a SIGHUP signal followed by a SIGCONT signal is sent to each process
+ * in the orphaned process group.
+ * Create a process in a stopped state to activate this behaviour.
+ */
+ const pid_t stopped = fork();
+ if (stopped < 0)
+ perror_msg_and_fail("fork");
+ if (!stopped) {
+ raise(SIGSTOP);
+ _exit(0);
+ }
+
+ /*
+ * Wait for the process to stop.
+ */
+ int status;
+ if (waitpid(stopped, &status, WUNTRACED) != stopped)
+ perror_msg_and_fail("waitpid WUNTRACED");
+ if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ error_msg_and_fail("waitpid WUNTRACED: "
+ "unexpected wait status %d", status);
+ /*
+ * Create all threads in a subprocess, this guarantees that
+ * their tracer will not be their parent.
+ */
+ pid_t pid = fork();
+ if (pid < 0)
+ perror_msg_and_fail("fork");
+ if (!pid) {
+ for (int i = 0; i < num_threads; i++) {
+ pthread_t t;
+ if ((errno = pthread_create(&t, NULL, thread, NULL))) {
+ if (EAGAIN == errno)
+ break;
+ perror_msg_and_fail("pthread_create #%d", i);
+ }
+ }
+
+ /* This terminates all threads created above. */
+ _exit(0);
+ }
+
+ if (waitpid(pid, &status, 0) != pid)
+ perror_msg_and_fail("waitpid");
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ error_msg_and_fail("waitpid: unexpected wait status %d",
+ status);
+
+ /*
+ * Make the process group orphaned.
+ */
+ return 0;
+}
Index: strace-4.24/tests-mx32/looping_threads.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-mx32/looping_threads.c 2020-01-27 17:41:26.671586776 +0100
@@ -0,0 +1,121 @@
+/*
+ * Check tracing of looping threads.
+ *
+ * Copyright (c) 2009-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static void *
+thread(void *arg)
+{
+ for (;;)
+ getuid();
+ return arg;
+}
+
+int
+main(int ac, const char *av[])
+{
+ assert(ac == 3);
+
+ int timeout = atoi(av[1]);
+ assert(timeout > 0);
+
+ int num_threads = atoi(av[2]);
+ assert(num_threads > 0);
+
+ /*
+ * Unblock all signals.
+ */
+ static sigset_t mask;
+ if (sigprocmask(SIG_SETMASK, &mask, NULL))
+ perror_msg_and_fail("sigprocmask");
+
+ /*
+ * Reset SIGALRM and SIGHUP signal handlers.
+ */
+ static const struct sigaction sa_def = { .sa_handler = SIG_DFL };
+ if (sigaction(SIGHUP, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGHUP");
+ if (sigaction(SIGALRM, &sa_def, NULL))
+ perror_msg_and_fail("sigaction SIGALRM");
+
+ /*
+ * Create a new process group.
+ */
+ if (setpgid(0, 0))
+ perror_msg_and_fail("setpgid");
+
+ /*
+ * Set an alarm clock.
+ */
+ alarm(timeout);
+
+ /*
+ * When the main process terminates, the process group becomes orphaned.
+ * If any member of the orphaned process group is stopped, then
+ * a SIGHUP signal followed by a SIGCONT signal is sent to each process
+ * in the orphaned process group.
+ * Create a process in a stopped state to activate this behaviour.
+ */
+ const pid_t stopped = fork();
+ if (stopped < 0)
+ perror_msg_and_fail("fork");
+ if (!stopped) {
+ raise(SIGSTOP);
+ _exit(0);
+ }
+
+ /*
+ * Wait for the process to stop.
+ */
+ int status;
+ if (waitpid(stopped, &status, WUNTRACED) != stopped)
+ perror_msg_and_fail("waitpid WUNTRACED");
+ if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ error_msg_and_fail("waitpid WUNTRACED: "
+ "unexpected wait status %d", status);
+ /*
+ * Create all threads in a subprocess, this guarantees that
+ * their tracer will not be their parent.
+ */
+ pid_t pid = fork();
+ if (pid < 0)
+ perror_msg_and_fail("fork");
+ if (!pid) {
+ for (int i = 0; i < num_threads; i++) {
+ pthread_t t;
+ if ((errno = pthread_create(&t, NULL, thread, NULL))) {
+ if (EAGAIN == errno)
+ break;
+ perror_msg_and_fail("pthread_create #%d", i);
+ }
+ }
+
+ /* This terminates all threads created above. */
+ _exit(0);
+ }
+
+ if (waitpid(pid, &status, 0) != pid)
+ perror_msg_and_fail("waitpid");
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ error_msg_and_fail("waitpid: unexpected wait status %d",
+ status);
+
+ /*
+ * Make the process group orphaned.
+ */
+ return 0;
+}
Index: strace-4.24/tests/Makefile.in
===================================================================
--- strace-4.24.orig/tests/Makefile.in 2020-01-27 17:41:26.655586889 +0100
+++ strace-4.24/tests/Makefile.in 2020-01-27 20:17:47.817414191 +0100
@@ -155,7 +155,7 @@
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
- localtime$(EXEEXT) \
+ localtime$(EXEEXT) looping_threads$(EXEEXT) \
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
@@ -1226,6 +1226,9 @@
lookup_dcookie_OBJECTS = lookup_dcookie.$(OBJEXT)
lookup_dcookie_LDADD = $(LDADD)
lookup_dcookie_DEPENDENCIES = libtests.a
+looping_threads_SOURCES = looping_threads.c
+looping_threads_OBJECTS = looping_threads.$(OBJEXT)
+looping_threads_DEPENDENCIES = $(LDADD)
lseek_SOURCES = lseek.c
lseek_OBJECTS = lseek.$(OBJEXT)
lseek_LDADD = $(LDADD)
@@ -2752,11 +2755,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -2898,11 +2902,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -3922,6 +3927,7 @@
fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
localtime_LDADD = $(clock_LIBS) $(LDADD)
+looping_threads_LDADD = -lpthread $(LDADD)
lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_Xabbrev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
@@ -4242,6 +4248,7 @@
kill_child.test \
ksysent.test \
localtime.test \
+ looping_threads.test \
opipe.test \
options-syntax.test \
pc.test \
@@ -5243,6 +5250,10 @@
@rm -f lookup_dcookie$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lookup_dcookie_OBJECTS) $(lookup_dcookie_LDADD) $(LIBS)
+looping_threads$(EXEEXT): $(looping_threads_OBJECTS) $(looping_threads_DEPENDENCIES) $(EXTRA_looping_threads_DEPENDENCIES)
+ @rm -f looping_threads$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(looping_threads_OBJECTS) $(looping_threads_LDADD) $(LIBS)
+
lseek$(EXEEXT): $(lseek_OBJECTS) $(lseek_DEPENDENCIES) $(EXTRA_lseek_DEPENDENCIES)
@rm -f lseek$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lseek_OBJECTS) $(lseek_LDADD) $(LIBS)
@@ -6912,6 +6923,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/llseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localtime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lookup_dcookie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/looping_threads.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat64-lstat64.Po@am__quote@
Index: strace-4.24/tests-m32/Makefile.in
===================================================================
--- strace-4.24.orig/tests-m32/Makefile.in 2020-01-27 17:41:26.657586875 +0100
+++ strace-4.24/tests-m32/Makefile.in 2020-01-27 20:17:47.817414191 +0100
@@ -155,7 +155,7 @@
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
- localtime$(EXEEXT) \
+ localtime$(EXEEXT) looping_threads$(EXEEXT) \
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
@@ -1226,6 +1226,9 @@
lookup_dcookie_OBJECTS = lookup_dcookie.$(OBJEXT)
lookup_dcookie_LDADD = $(LDADD)
lookup_dcookie_DEPENDENCIES = libtests.a
+looping_threads_SOURCES = looping_threads.c
+looping_threads_OBJECTS = looping_threads.$(OBJEXT)
+looping_threads_DEPENDENCIES = $(LDADD)
lseek_SOURCES = lseek.c
lseek_OBJECTS = lseek.$(OBJEXT)
lseek_LDADD = $(LDADD)
@@ -2752,11 +2755,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -2898,11 +2902,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -3922,6 +3927,7 @@
fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
localtime_LDADD = $(clock_LIBS) $(LDADD)
+looping_threads_LDADD = -lpthread $(LDADD)
lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_Xabbrev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
@@ -4242,6 +4248,7 @@
kill_child.test \
ksysent.test \
localtime.test \
+ looping_threads.test \
opipe.test \
options-syntax.test \
pc.test \
@@ -5243,6 +5250,10 @@
@rm -f lookup_dcookie$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lookup_dcookie_OBJECTS) $(lookup_dcookie_LDADD) $(LIBS)
+looping_threads$(EXEEXT): $(looping_threads_OBJECTS) $(looping_threads_DEPENDENCIES) $(EXTRA_looping_threads_DEPENDENCIES)
+ @rm -f looping_threads$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(looping_threads_OBJECTS) $(looping_threads_LDADD) $(LIBS)
+
lseek$(EXEEXT): $(lseek_OBJECTS) $(lseek_DEPENDENCIES) $(EXTRA_lseek_DEPENDENCIES)
@rm -f lseek$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lseek_OBJECTS) $(lseek_LDADD) $(LIBS)
@@ -6912,6 +6923,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/llseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localtime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lookup_dcookie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/looping_threads.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat64-lstat64.Po@am__quote@
Index: strace-4.24/tests-mx32/Makefile.in
===================================================================
--- strace-4.24.orig/tests-mx32/Makefile.in 2020-01-27 17:41:26.658586868 +0100
+++ strace-4.24/tests-mx32/Makefile.in 2020-01-27 20:17:47.817414191 +0100
@@ -155,7 +155,7 @@
ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
ksysent$(EXEEXT) list_sigaction_signum$(EXEEXT) \
- localtime$(EXEEXT) \
+ localtime$(EXEEXT) looping_threads$(EXEEXT) \
mmsg-silent$(EXEEXT) mmsg_name-v$(EXEEXT) \
msg_control-v$(EXEEXT) net-accept-connect$(EXEEXT) \
net-tpacket_stats-success$(EXEEXT) netlink_inet_diag$(EXEEXT) \
@@ -1226,6 +1226,9 @@
lookup_dcookie_OBJECTS = lookup_dcookie.$(OBJEXT)
lookup_dcookie_LDADD = $(LDADD)
lookup_dcookie_DEPENDENCIES = libtests.a
+looping_threads_SOURCES = looping_threads.c
+looping_threads_OBJECTS = looping_threads.$(OBJEXT)
+looping_threads_DEPENDENCIES = $(LDADD)
lseek_SOURCES = lseek.c
lseek_OBJECTS = lseek.$(OBJEXT)
lseek_LDADD = $(LDADD)
@@ -2752,11 +2755,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -2898,11 +2902,12 @@
kexec_file_load.c kexec_load.c keyctl.c keyctl-Xabbrev.c \
keyctl-Xraw.c keyctl-Xverbose.c kill.c kill_child.c ksysent.c \
lchown.c lchown32.c link.c linkat.c list_sigaction_signum.c \
- llseek.c localtime.c lookup_dcookie.c lseek.c lstat.c lstat64.c \
- madvise.c mbind.c membarrier.c memfd_create.c migrate_pages.c \
- mincore.c mkdir.c mkdirat.c mknod.c mknodat.c mlock.c mlock2.c \
- mlockall.c mmap.c mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c \
- mmap64.c mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
+ llseek.c localtime.c lookup_dcookie.c looping_threads.c \
+ lseek.c lstat.c lstat64.c madvise.c mbind.c membarrier.c \
+ memfd_create.c migrate_pages.c mincore.c mkdir.c mkdirat.c \
+ mknod.c mknodat.c mlock.c mlock2.c mlockall.c mmap.c \
+ mmap-Xabbrev.c mmap-Xraw.c mmap-Xverbose.c mmap64.c \
+ mmap64-Xabbrev.c mmap64-Xraw.c mmap64-Xverbose.c \
mmsg.c mmsg-silent.c mmsg_name.c mmsg_name-v.c modify_ldt.c \
mount.c mount-Xabbrev.c mount-Xraw.c mount-Xverbose.c \
move_pages.c mq.c mq_sendrecv.c mq_sendrecv-read.c \
@@ -3922,6 +3927,7 @@
fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
localtime_LDADD = $(clock_LIBS) $(LDADD)
+looping_threads_LDADD = -lpthread $(LDADD)
lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
mmap64_Xabbrev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
@@ -4242,6 +4248,7 @@
kill_child.test \
ksysent.test \
localtime.test \
+ looping_threads.test \
opipe.test \
options-syntax.test \
pc.test \
@@ -5243,6 +5250,10 @@
@rm -f lookup_dcookie$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lookup_dcookie_OBJECTS) $(lookup_dcookie_LDADD) $(LIBS)
+looping_threads$(EXEEXT): $(looping_threads_OBJECTS) $(looping_threads_DEPENDENCIES) $(EXTRA_looping_threads_DEPENDENCIES)
+ @rm -f looping_threads$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(looping_threads_OBJECTS) $(looping_threads_LDADD) $(LIBS)
+
lseek$(EXEEXT): $(lseek_OBJECTS) $(lseek_DEPENDENCIES) $(EXTRA_lseek_DEPENDENCIES)
@rm -f lseek$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lseek_OBJECTS) $(lseek_LDADD) $(LIBS)
@@ -6912,6 +6923,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/llseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localtime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lookup_dcookie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/looping_threads.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat64-lstat64.Po@am__quote@
Index: strace-4.24/tests-m32/looping_threads.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-m32/looping_threads.test 2020-01-27 20:18:24.992072957 +0100
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Check tracing of looping threads.
+#
+# Copyright (c) 2009-2019 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+. "${srcdir=.}/PTRACE_SEIZE.sh"
+
+run_prog ../orphaned_process_group > /dev/null
+
+run_prog_skip_if_failed date +%s > /dev/null
+s0="$(date +%s)"
+
+check_prog nproc
+inc="$(nproc)"
+[ "$inc" -ge 1 ] || inc=1
+
+timeout_2="$(($TIMEOUT_DURATION/2))"
+timeout_8="$(($TIMEOUT_DURATION/8))"
+nproc=1
+
+run_prog "../$NAME" "$timeout_8" "$nproc"
+
+while :; do
+ run_strace -f -qq -enone -esignal=none "../$NAME" "$timeout_2" "$nproc"
+
+ s1="$(date +%s)"
+ [ "$(($s1-$s0))" -lt "$timeout_8" ] ||
+ break
+
+ nproc="$(($nproc+$inc))"
+done
+
+warn_ "$ME_: nproc=$nproc elapsed=$(($s1-$s0))"
Index: strace-4.24/tests-mx32/looping_threads.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-mx32/looping_threads.test 2020-01-27 20:18:26.879055636 +0100
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Check tracing of looping threads.
+#
+# Copyright (c) 2009-2019 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+. "${srcdir=.}/init.sh"
+. "${srcdir=.}/PTRACE_SEIZE.sh"
+
+run_prog ../orphaned_process_group > /dev/null
+
+run_prog_skip_if_failed date +%s > /dev/null
+s0="$(date +%s)"
+
+check_prog nproc
+inc="$(nproc)"
+[ "$inc" -ge 1 ] || inc=1
+
+timeout_2="$(($TIMEOUT_DURATION/2))"
+timeout_8="$(($TIMEOUT_DURATION/8))"
+nproc=1
+
+run_prog "../$NAME" "$timeout_8" "$nproc"
+
+while :; do
+ run_strace -f -qq -enone -esignal=none "../$NAME" "$timeout_2" "$nproc"
+
+ s1="$(date +%s)"
+ [ "$(($s1-$s0))" -lt "$timeout_8" ] ||
+ break
+
+ nproc="$(($nproc+$inc))"
+done
+
+warn_ "$ME_: nproc=$nproc elapsed=$(($s1-$s0))"