mirror of
https://github.com/golang/go
synced 2024-11-17 05:14:56 -07:00
cmd/compile: fix deadlock on syntax error
Fixes #52127 Change-Id: I6523c83350cb9263d23e3e8b472fe63a5cc99c2e Reviewed-on: https://go-review.googlesource.com/c/go/+/398014 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
c451a02a6d
commit
5a90270d7f
@ -33,15 +33,19 @@ func LoadPackage(filenames []string) {
|
||||
sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10)
|
||||
|
||||
noders := make([]*noder, len(filenames))
|
||||
for i, filename := range filenames {
|
||||
for i := range noders {
|
||||
p := noder{
|
||||
err: make(chan syntax.Error),
|
||||
}
|
||||
noders[i] = &p
|
||||
}
|
||||
|
||||
filename := filename
|
||||
go func() {
|
||||
for i, filename := range filenames {
|
||||
filename := filename
|
||||
p := noders[i]
|
||||
sem <- struct{}{}
|
||||
go func() {
|
||||
defer func() { <-sem }()
|
||||
defer close(p.err)
|
||||
fbase := syntax.NewFileBase(filename)
|
||||
@ -56,6 +60,7 @@ func LoadPackage(filenames []string) {
|
||||
p.file, _ = syntax.Parse(fbase, f, p.error, p.pragma, mode) // errors are tracked via p.error
|
||||
}()
|
||||
}
|
||||
}()
|
||||
|
||||
var lines uint
|
||||
for _, p := range noders {
|
||||
|
Loading…
Reference in New Issue
Block a user