Log go/analysis panics, don't crash
go/analysis panics were propagated to main and crashed golangci-lint. Just log them, as with other linters. Found in #608.
This commit is contained in:
parent
f1c1dbfab4
commit
4495f893b9
4
Makefile
4
Makefile
@ -5,11 +5,13 @@
|
||||
|
||||
fast_build: FORCE
|
||||
go build -o golangci-lint ./cmd/golangci-lint
|
||||
build_race: FORCE
|
||||
go build -race -o golangci-lint ./cmd/golangci-lint
|
||||
build: golangci-lint
|
||||
clean:
|
||||
rm -f golangci-lint test/path
|
||||
rm -rf tools
|
||||
.PHONY: fast_build build clean
|
||||
.PHONY: fast_build build build_race clean
|
||||
|
||||
# Test
|
||||
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
"sort"
|
||||
@ -285,11 +286,17 @@ func (act *action) String() string {
|
||||
func execAll(actions []*action) {
|
||||
sequential := dbg('p')
|
||||
var wg sync.WaitGroup
|
||||
for _, act := range actions {
|
||||
panics := make([]interface{}, len(actions))
|
||||
for i, act := range actions {
|
||||
wg.Add(1)
|
||||
work := func(act *action) {
|
||||
defer func() {
|
||||
wg.Done()
|
||||
if p := recover(); p != nil {
|
||||
panics[i] = fmt.Errorf("%s: %s", p, debug.Stack())
|
||||
}
|
||||
}()
|
||||
act.exec()
|
||||
wg.Done()
|
||||
}
|
||||
if sequential {
|
||||
work(act)
|
||||
@ -298,6 +305,11 @@ func execAll(actions []*action) {
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
for _, p := range panics {
|
||||
if p != nil {
|
||||
panic(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (act *action) exec() { act.once.Do(act.execOnce) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user