From 27f5dfefff3cd00795d9048ecc7bc70965e03ea7 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Fri, 8 Dec 2017 20:17:13 +0100 Subject: pkg/report: improve report header extraction Allow stack traces to be intermixed with random kernel messages that don't start with a ' ' char (all frames in a stack trace do). Also improve report headers for BUGs from mm/usercopy.c, as we get quite a lot of those. --- pkg/report/linux.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'pkg/report/linux.go') diff --git a/pkg/report/linux.go b/pkg/report/linux.go index d0be1acd8..17b99aa0e 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -69,6 +69,9 @@ func ctorLinux(kernelSrc, kernelObj string, symbols map[string][]symbolizer.Symb regexp.MustCompile(`^kernel/locking/*`), regexp.MustCompile(`^kernel/panic.c`), regexp.MustCompile(`^kernel/softirq.c`), + regexp.MustCompile(`^kernel/kthread.c`), + regexp.MustCompile(`^kernel/sched/*.c`), + regexp.MustCompile(`^kernel/time/timer.c`), regexp.MustCompile(`^net/core/dev.c`), regexp.MustCompile(`^net/core/sock.c`), regexp.MustCompile(`^net/core/skbuff.c`), @@ -433,6 +436,16 @@ var linuxStackKeywords = []*regexp.Regexp{ regexp.MustCompile(`[^k] backtrace:`), } +func stacktraceRe(frameBlacklist ...string) string { + consumeRe := "(?:[^ ].*\\n)*" + if len(frameBlacklist) > 0 { + blacklistRe := "(?:" + strings.Join(frameBlacklist, "|") + ")" + blacklistFrameRe := "(?:.*" + blacklistRe + ".*\\n)" + consumeRe = "(?:" + blacklistFrameRe + "|" + "(?:[^ ].*\\n)" + ")*" + } + return consumeRe + " (?:{{PC}} )?{{FUNC}}" +} + var linuxOopses = []*oops{ &oops{ []byte("BUG:"), @@ -662,7 +675,7 @@ var linuxOopses = []*oops{ fmt: "inconsistent lock state in %[1]v", }, { - title: compile("INFO: rcu_(?:preempt|sched|bh) detected(?: expedited)? stalls(?:.*\\n)+?.*.*\n(?:.*rcu.*\\n)+? {{FUNC}}"), + title: compile("INFO: rcu_(?:preempt|sched|bh) detected(?: expedited)? stalls(?:.*\\n)+?.*.*\\n" + stacktraceRe("rcu")), fmt: "INFO: rcu detected stall in %[1]v", }, { @@ -670,7 +683,7 @@ var linuxOopses = []*oops{ fmt: "INFO: rcu detected stall", }, { - title: compile("INFO: rcu_(?:preempt|sched|bh) self-detected stall on CPU(?:.*\\n)+?.*.*\n(?:.*rcu.*\\n)+? {{FUNC}}"), + title: compile("INFO: rcu_(?:preempt|sched|bh) self-detected stall on CPU(?:.*\\n)+?.*.*\\n" + stacktraceRe("rcu")), fmt: "INFO: rcu detected stall in %[1]v", }, { @@ -678,7 +691,7 @@ var linuxOopses = []*oops{ fmt: "INFO: rcu detected stall", }, { - title: compile("INFO: trying to register non-static key(?:.*\\n){0,10}Call Trace:\\n(?:(?:.*stack.*\\n)|(?:.*lock.*\\n)|(?:.*IRQ.*\\n))+ {{FUNC}}"), + title: compile("INFO: trying to register non-static key(?:.*\\n){0,10}Call Trace:\\n" + stacktraceRe("stack", "lock", "IRQ")), fmt: "INFO: trying to register non-static key in %[1]v", }, { @@ -695,7 +708,7 @@ var linuxOopses = []*oops{ corrupted: true, }, { - title: compile("INFO: task .* blocked for more than [0-9]+ seconds(?:.*\\n){0,10}Call Trace:\\n(?:.*(?:sched|_lock|completion|kthread).*\\n)* (?:{{PC}} )?{{FUNC}}"), + title: compile("INFO: task .* blocked for more than [0-9]+ seconds(?:.*\\n){0,10}Call Trace:\\n" + stacktraceRe("sched", "_lock", "completion", "kthread")), fmt: "INFO: task hung in %[1]v", }, { @@ -775,6 +788,10 @@ var linuxOopses = []*oops{ &oops{ []byte("kernel BUG"), []oopsFormat{ + { + title: compile("kernel BUG at mm/usercopy.c(?:.*\\n)+?Call Trace:\\n" + stacktraceRe()), + fmt: "BUG: bad usercopy in %[1]v", + }, { title: compile("kernel BUG (.*)"), fmt: "kernel BUG %[1]v", -- cgit mrf-deployment