diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-12-07 07:57:07 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-07 08:54:15 +0100 |
| commit | f80ce148aeb891e3335fb38ed9b48b005ca76529 (patch) | |
| tree | b041e1c8daf07c1f4fb38c0b3f278b20ec8d5043 /pkg/report/linux.go | |
| parent | 57072f7b90ab8851dfeddcfa531c5b91486b69da (diff) | |
pkg/report: better guilty file extraction with lockdep header
LOCKDEP can add "hard/softirs last enabled/disabled at" lines
with more files at the top. These files are generally not related,
or at least out of order. We want to extract the file from stacks,
so ignore these lines.
Diffstat (limited to 'pkg/report/linux.go')
| -rw-r--r-- | pkg/report/linux.go | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go index 687069501..fe649088f 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -27,6 +27,7 @@ type linux struct { cpuContext *regexp.Regexp questionableFrame *regexp.Regexp guiltyFileIgnores []*regexp.Regexp + guiltyLineIgnore *regexp.Regexp reportStartIgnores []*regexp.Regexp infoMessagesWithStack [][]byte eoi []byte @@ -87,6 +88,7 @@ func ctorLinux(cfg *config) (Reporter, []string, error) { regexp.MustCompile(`^trusty/`), // Trusty sources are not in linux kernel tree. regexp.MustCompile(`^drivers/usb/core/urb.c`), // WARNING in urb.c usually means a bug in a driver } + ctx.guiltyLineIgnore = regexp.MustCompile(`(hardirqs|softirqs)\s+last\s+(enabled|disabled)`) // These pattern do _not_ start a new report, i.e. can be in a middle of another report. ctx.reportStartIgnores = []*regexp.Regexp{ compile(`invalid opcode: 0000`), @@ -446,23 +448,27 @@ func (ctx *linux) extractGuiltyFile(rep *Report) string { } func (ctx *linux) extractGuiltyFileImpl(report []byte) string { - files := ctx.extractFiles(report) -nextFile: - for _, file := range files { - for _, re := range ctx.guiltyFileIgnores { - if re.MatchString(file) { - continue nextFile - } + var first []byte + for s := bufio.NewScanner(bytes.NewReader(report)); s.Scan(); { + match := filenameRe.FindSubmatch(s.Bytes()) + if match == nil { + continue } - return file - } - // Avoid producing no guilty file at all, otherwise we mail the report to nobody. - // It's unclear if it's better to return the first one or the last one. - // So far the only test we have has only one file anyway. - if len(files) != 0 { - return files[0] + file := match[1] + if len(first) == 0 { + // Avoid producing no guilty file at all, otherwise we mail the report to nobody. + // It's unclear if it's better to return the first one or the last one. + // So far the only test we have has only one file anyway. + first = file + } + + if matchesAny(file, ctx.guiltyFileIgnores) || ctx.guiltyLineIgnore.Match(s.Bytes()) { + continue + } + first = file + break } - return "" + return filepath.Clean(string(first)) } func (ctx *linux) getMaintainers(file string) (vcs.Recipients, error) { @@ -501,16 +507,6 @@ func getMaintainersImpl(kernelSrc, file string, blame bool) (vcs.Recipients, err return vcs.ParseMaintainersLinux(output), nil } -func (ctx *linux) extractFiles(report []byte) []string { - matches := filenameRe.FindAll(report, -1) - var files []string - for _, match := range matches { - f := string(bytes.Split(match, []byte{':'})[0]) - files = append(files, filepath.Clean(f)) - } - return files -} - func (ctx *linux) isCorrupted(title string, report []byte, format oopsFormat) (bool, string) { // Check for common title corruptions. for _, re := range linuxCorruptedTitles { |
