From 3f1ed245510d21ad021ea96da7bbd37ec2aca9ed Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 1 Nov 2016 12:27:26 -0700 Subject: [PATCH] cmd/compile/internal/syntax: avoid deadlock When the err from ReadFile is non-nil, we call t.Fatal(err). Switch t.Fatal to t.Error + return. ensure that close(results) happens on that code path as well. Updates #17697. Change-Id: Ifaacf27a76c175446d642086ff32f4386428080d Reviewed-on: https://go-review.googlesource.com/32486 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Robert Griesemer Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/syntax/parser_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go index 780f10835c..3cb12c23d5 100644 --- a/src/cmd/compile/internal/syntax/parser_test.go +++ b/src/cmd/compile/internal/syntax/parser_test.go @@ -44,6 +44,7 @@ func TestStdLib(t *testing.T) { results := make(chan parseResult) go func() { + defer close(results) for _, dir := range []string{ runtime.GOROOT(), //"/Users/gri/src", @@ -54,7 +55,8 @@ func TestStdLib(t *testing.T) { } ast, err := ReadFile(filename, nil, nil, 0) if err != nil { - t.Fatal(err) + t.Error(err) + return } if *verify { verifyPrint(filename, ast) @@ -62,7 +64,6 @@ func TestStdLib(t *testing.T) { results <- parseResult{filename, ast.Lines} }) } - close(results) }() var count, lines int