Running the perf test command after building perf with a memory
sanitizer causes a warning that says:
WARNING: MemorySanitizer: use-of-uninitialized-value... in mmap-thread-lookup.c
Initializing the go variable to 0 fixes this change.
Signed-off-by: Numfor Mbiziwo-Tiapo <[email protected]>
---
tools/perf/tests/mmap-thread-lookup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index 5ede9b561d32..b1abf4752f35 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -52,7 +52,7 @@ static void *thread_fn(void *arg)
{
struct thread_data *td = arg;
ssize_t ret;
- int go;
+ int go = 0;
if (thread_init(td))
return NULL;
--
2.22.0.410.gd8fdbe21b5-goog
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.
Signed-off-by: Numfor Mbiziwo-Tiapo <[email protected]>
---
tools/perf/tests/perf-hooks.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
index a693bcf017ea..524ecba63615 100644
--- a/tools/perf/tests/perf-hooks.c
+++ b/tools/perf/tests/perf-hooks.c
@@ -25,7 +25,12 @@ static void the_hook(void *_hook_flags)
*hook_flags = 1234;
/* Generate a segfault, test perf_hooks__recover */
+#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
+defined(THREAD_SANITIZER) || defined(SAFESTACK_SANITIZER)
+ raise(SIGSEGV);
+#else
*p = 0;
+#endif
}
int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
--
2.22.0.410.gd8fdbe21b5-goog
Em Tue, Jul 02, 2019 at 10:37:15AM -0700, Numfor Mbiziwo-Tiapo escreveu:
> Running the perf test command after building perf with a memory
> sanitizer causes a warning that says:
> WARNING: MemorySanitizer: use-of-uninitialized-value... in mmap-thread-lookup.c
> Initializing the go variable to 0 fixes this change.
>
> Signed-off-by: Numfor Mbiziwo-Tiapo <[email protected]>
> ---
> tools/perf/tests/mmap-thread-lookup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
> index 5ede9b561d32..b1abf4752f35 100644
> --- a/tools/perf/tests/mmap-thread-lookup.c
> +++ b/tools/perf/tests/mmap-thread-lookup.c
> @@ -52,7 +52,7 @@ static void *thread_fn(void *arg)
> {
> struct thread_data *td = arg;
> ssize_t ret;
> - int go;
> + int go = 0;
>
> if (thread_init(td))
> return NULL;
The test needs to write something to a file, whatever, so this doesn't
fix anything, just silences the compiler warning, which is a good thing.
I'll apply and adjust the cset commit log.
Thanks,
- Arnaldo
Em Tue, Jul 02, 2019 at 10:37:16AM -0700, Numfor Mbiziwo-Tiapo escreveu:
> 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.
Can you please add to the commit log message, here, the sequence of
steps needed to build with these sanitizers, so that one can replicate
the steps and reproduce the results?
- Arnaldo
> Signed-off-by: Numfor Mbiziwo-Tiapo <[email protected]>
> ---
> tools/perf/tests/perf-hooks.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
> index a693bcf017ea..524ecba63615 100644
> --- a/tools/perf/tests/perf-hooks.c
> +++ b/tools/perf/tests/perf-hooks.c
> @@ -25,7 +25,12 @@ static void the_hook(void *_hook_flags)
> *hook_flags = 1234;
>
> /* Generate a segfault, test perf_hooks__recover */
> +#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
> +defined(THREAD_SANITIZER) || defined(SAFESTACK_SANITIZER)
> + raise(SIGSEGV);
> +#else
> *p = 0;
> +#endif
> }
>
> int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
> --
> 2.22.0.410.gd8fdbe21b5-goog
--
- Arnaldo
Commit-ID: 4e4cf62b37da5ff45c904a3acf242ab29ed5881d
Gitweb: https://git.kernel.org/tip/4e4cf62b37da5ff45c904a3acf242ab29ed5881d
Author: Numfor Mbiziwo-Tiapo <[email protected]>
AuthorDate: Tue, 2 Jul 2019 10:37:15 -0700
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 9 Jul 2019 09:33:54 -0300
perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning
Running the 'perf test' command after building perf with a memory
sanitizer causes a warning that says:
WARNING: MemorySanitizer: use-of-uninitialized-value... in mmap-thread-lookup.c
Initializing the go variable to 0 silences this harmless warning.
Committer warning:
This was harmless, just a simple test writing whatever was at that
sizeof(int) memory area just to signal another thread blocked reading
that file created with pipe(). Initialize it tho so that we don't get
this warning.
Signed-off-by: Numfor Mbiziwo-Tiapo <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Drayton <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/tests/mmap-thread-lookup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index ba87e6e8d18c..0a4301a5155c 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -53,7 +53,7 @@ static void *thread_fn(void *arg)
{
struct thread_data *td = arg;
ssize_t ret;
- int go;
+ int go = 0;
if (thread_init(td))
return NULL;