[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190708215928.167905-1-nums@google.com>
Date: Mon, 8 Jul 2019 14:59:28 -0700
From: Numfor Mbiziwo-Tiapo <nums@...gle.com>
To: peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, songliubraving@...com, mbd@...com
Cc: linux-kernel@...r.kernel.org, irogers@...gle.com,
eranian@...gle.com, Numfor Mbiziwo-Tiapo <nums@...gle.com>
Subject: [PATCH] Fix perf-hooks test for sanitizers
The perf-hooks test fails with Address Sanitizer and Memory
Sanitizer builds because it purposefully generates a segfault.
Checking if these sanitizers are active when running this test
will allow the perf-hooks test to pass.
This can be replicated by running (from the tip directory):
make -C tools/perf USE_CLANG=1 EXTRA_CFLAGS="-fsanitize=address \
-DADDRESS_SANITIZER=1"
then running tools/perf/perf test 55
Fix past to pass:
The raised signal was changed from SIGSEGV to SIGILL to get the test
to pass on our local machines which use clang 4.
Signed-off-by: Numfor Mbiziwo-Tiapo <nums@...gle.com>
---
tools/perf/tests/perf-hooks.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
index a693bcf017ea..3f5f4b28cf01 100644
--- a/tools/perf/tests/perf-hooks.c
+++ b/tools/perf/tests/perf-hooks.c
@@ -7,7 +7,14 @@
#include "util.h"
#include "perf-hooks.h"
-static void sigsegv_handler(int sig __maybe_unused)
+#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
+defined(THREAD_SANITIZER) || defined(SAFESTACK_SANITIZER)
+#define USE_SIGNAL 1
+#else
+#define USE_SIGNAL 0
+#endif
+
+static void signal_handler(int sig __maybe_unused)
{
pr_debug("SIGSEGV is observed as expected, try to recover.\n");
perf_hooks__recover();
@@ -25,6 +32,9 @@ static void the_hook(void *_hook_flags)
*hook_flags = 1234;
/* Generate a segfault, test perf_hooks__recover */
+#if USE_SIGNAL
+ raise(SIGILL);
+#endif
*p = 0;
}
@@ -32,7 +42,7 @@ int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unuse
{
int hook_flags = 0;
- signal(SIGSEGV, sigsegv_handler);
+ signal(USE_SIGNAL ? SIGILL : SIGSEGV, signal_handler);
perf_hooks__set_hook("test", the_hook, &hook_flags);
perf_hooks__invoke_test();
--
2.22.0.410.gd8fdbe21b5-goog
Powered by blists - more mailing lists