linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage
@ 2019-07-02 17:37 Numfor Mbiziwo-Tiapo
  2019-07-02 17:37 ` [PATCH 2/2] Fix perf-hooks test Numfor Mbiziwo-Tiapo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Numfor Mbiziwo-Tiapo @ 2019-07-02 17:37 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	songliubraving, mbd
  Cc: linux-kernel, irogers, eranian, Numfor Mbiziwo-Tiapo

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 <nums@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Fix perf-hooks test
  2019-07-02 17:37 [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Numfor Mbiziwo-Tiapo
@ 2019-07-02 17:37 ` Numfor Mbiziwo-Tiapo
  2019-07-05 16:40   ` Arnaldo Carvalho de Melo
  2019-07-03  3:09 ` [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Arnaldo Carvalho de Melo
  2019-07-13 10:52 ` [tip:perf/urgent] perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning tip-bot for Numfor Mbiziwo-Tiapo
  2 siblings, 1 reply; 5+ messages in thread
From: Numfor Mbiziwo-Tiapo @ 2019-07-02 17:37 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	songliubraving, mbd
  Cc: linux-kernel, irogers, eranian, Numfor Mbiziwo-Tiapo

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 <nums@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage
  2019-07-02 17:37 [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Numfor Mbiziwo-Tiapo
  2019-07-02 17:37 ` [PATCH 2/2] Fix perf-hooks test Numfor Mbiziwo-Tiapo
@ 2019-07-03  3:09 ` Arnaldo Carvalho de Melo
  2019-07-13 10:52 ` [tip:perf/urgent] perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning tip-bot for Numfor Mbiziwo-Tiapo
  2 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-07-03  3:09 UTC (permalink / raw)
  To: Numfor Mbiziwo-Tiapo
  Cc: peterz, mingo, alexander.shishkin, jolsa, namhyung,
	songliubraving, mbd, linux-kernel, irogers, eranian

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 <nums@google.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Fix perf-hooks test
  2019-07-02 17:37 ` [PATCH 2/2] Fix perf-hooks test Numfor Mbiziwo-Tiapo
@ 2019-07-05 16:40   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-07-05 16:40 UTC (permalink / raw)
  To: Numfor Mbiziwo-Tiapo
  Cc: peterz, mingo, alexander.shishkin, jolsa, namhyung,
	songliubraving, mbd, linux-kernel, irogers, eranian

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 <nums@google.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:perf/urgent] perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning
  2019-07-02 17:37 [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Numfor Mbiziwo-Tiapo
  2019-07-02 17:37 ` [PATCH 2/2] Fix perf-hooks test Numfor Mbiziwo-Tiapo
  2019-07-03  3:09 ` [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Arnaldo Carvalho de Melo
@ 2019-07-13 10:52 ` tip-bot for Numfor Mbiziwo-Tiapo
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Numfor Mbiziwo-Tiapo @ 2019-07-13 10:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mbd, linux-kernel, mingo, namhyung, hpa, irogers,
	alexander.shishkin, songliubraving, tglx, eranian, jolsa, acme,
	peterz, nums

Commit-ID:  4e4cf62b37da5ff45c904a3acf242ab29ed5881d
Gitweb:     https://git.kernel.org/tip/4e4cf62b37da5ff45c904a3acf242ab29ed5881d
Author:     Numfor Mbiziwo-Tiapo <nums@google.com>
AuthorDate: Tue, 2 Jul 2019 10:37:15 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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 <nums@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Drayton <mbd@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190702173716.181223-1-nums@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-13 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 17:37 [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Numfor Mbiziwo-Tiapo
2019-07-02 17:37 ` [PATCH 2/2] Fix perf-hooks test Numfor Mbiziwo-Tiapo
2019-07-05 16:40   ` Arnaldo Carvalho de Melo
2019-07-03  3:09 ` [PATCH 1/2] Fix mmap-thread-lookup.c unitialized memory usage Arnaldo Carvalho de Melo
2019-07-13 10:52 ` [tip:perf/urgent] perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning tip-bot for Numfor Mbiziwo-Tiapo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).