Skip to content

Commit 07f2b12

Browse files
captain5050acmel
authored andcommitted
perf test demangle-java: Don't segv if demangling fails
The buffer returned by dso__demangle_sym() may be NULL, don't segv in strcmp if this happens. Currently this happens for NO_LIBELF=1 builds. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alex Gaynor <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alice Ryhl <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andreas Hindborg <[email protected]> Cc: Benno Lossin <[email protected]> Cc: Björn Roy Baron <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Dmitriy Vyukov <[email protected]> Cc: Gary Guo <[email protected]> Cc: Howard Chu <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiapeng Chong <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephen Brennan <[email protected]> Cc: Trevor Gross <[email protected]> Cc: Weilin Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent fef8f64 commit 07f2b12

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/perf/tests/demangle-java-test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ static int test__demangle_java(struct test_suite *test __maybe_unused, int subte
3030

3131
for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
3232
buf = dso__demangle_sym(/*dso=*/NULL, /*kmodule=*/0, test_cases[i].mangled);
33+
if (!buf) {
34+
pr_debug("FAILED to demangle: \"%s\"\n \"%s\"\n", test_cases[i].mangled,
35+
test_cases[i].demangled);
36+
continue;
37+
}
3338
if (strcmp(buf, test_cases[i].demangled)) {
3439
pr_debug("FAILED: %s: %s != %s\n", test_cases[i].mangled,
3540
buf, test_cases[i].demangled);

0 commit comments

Comments
 (0)