Fix mmap-thread-lookup.c unitialized memory usage
PATCH 1/2 Fix mmap-thread-lookup.c unitialized memory usage
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.
--- tools/perf/tests/mmap-thread-lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/mmap-thread-lookup.c +1 -1
@@ -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 ;
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
PATCH 2/2 Fix perf-hooks test
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.
--- tools/perf/tests/perf-hooks.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/tests/perf-hooks.c +5 -0
@@ -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 )
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Re: [PATCH 2/2] Fix perf-hooks test
Em Tue, Jul 02, 2019 at 10:37:16AM -0700, Numfor Mbiziwo-Tiapo escreveu:
Quoted 4 lines
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
Quoted 24 lines
Signed-off-by Numfor Mbiziwo-Tiapo <[email protected]>--- tools/perf/tests/perf-hooks.c | 5 +++++ 1 file changed, 5 insertions(+)tools/perf/tests/perf-hooks.c +5
-0@@ -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 )Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Signature · 1 line
- Arnaldo
Em Tue, Jul 02, 2019 at 10:37:15AM -0700, Numfor Mbiziwo-Tiapo escreveu:
Quoted 15 lines
Running the perf test command after building perf with a memory sanitizer causes a warning that says:
WARNING: MemorySanitizer: use-of-uninitialized-value... inmmap-thread-lookup.cInitializing 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(-)tools/perf/tests/mmap-thread-lookup.c +0
-0
tools/perf/tests/mmap-thread-lookup.c static void *thread_fn(void *arg) · line 58
Quoted 8 lines
tools/perf/tests/mmap-thread-lookup.c +1
-1@@ -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
tip-bot for Numfor Mbiziwo-Tiapo
merge bot[tip:perf/urgent] perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning
In reply to Numfor Mbiziwo-Tiapoperf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning
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.
--- tools/perf/tests/mmap-thread-lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/mmap-thread-lookup.c +1 -1
@@ -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 ;