3 //go:build !js && !wasip1
5 // Copyright 2022 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
9 // Issue 52127: Too many syntax errors in many files can
10 // cause deadlocks instead of displaying error messages
24 dir, err := os.MkdirTemp("", "issue52127")
28 defer os.RemoveAll(dir)
30 args := []string{"go", "build"}
31 write := func(prefix string, i int, data string) {
32 filename := filepath.Join(dir, fmt.Sprintf("%s%d.go", prefix, i))
33 if err := os.WriteFile(filename, []byte(data), 0o644); err != nil {
36 args = append(args, filename)
39 for i := 0; i < 100; i++ {
40 write("a", i, `package p
43 for i := 0; i < 100; i++ {
44 write("b", i, `package p
53 cmd := exec.Command(args[0], args[1:]...)
54 output, err := cmd.CombinedOutput()
56 panic("compile succeeded unexpectedly")
58 if !bytes.Contains(output, []byte("syntax error:")) {
59 panic(fmt.Sprintf(`missing "syntax error" in compiler output; got: