Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: data races resulting from package mutation in NewChecker #61212

Closed
adonovan opened this issue Jul 6, 2023 · 9 comments
Closed

go/types: data races resulting from package mutation in NewChecker #61212

adonovan opened this issue Jul 6, 2023 · 9 comments
Assignees
Labels
FrozenDueToAge release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Jul 6, 2023

#!watchflakes
post <- log ~ `WARNING: DATA RACE` && log ~ `\s+go/types\.NewChecker\(\)` && date < "2023-07-08"

https://storage.googleapis.com/go-build-log/449ef379/linux-amd64-race_bbcd4378.log

package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (/go/src/c/x.go:1:8: expected 'IDENT', found 'EOF')
/go/src/c/x.go:1:20: expected operand, found 'EOF'
cannot find package "two/three" in any of:
	/go/src/two/three (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath')
cannot find package "http" in any of:
	/go/src/vendor/http (vendor tree)
	/go/src/http (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath')
/go/src/c/x.go:1:31: cannot convert false (untyped bool constant) to type int
==================
WARNING: DATA RACE
Write at 0x00c00007c288 by goroutine 1882:
  go/types.NewChecker()
      /workdir/go/src/go/types/check.go:240 +0xfd
  golang.org/x/tools/go/loader.(*importer).newPackageInfo()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:1053 +0x836
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:961 +0xa4
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45

Previous write at 0x00c00007c288 by goroutine 1888:
  go/types.NewChecker()
      /workdir/go/src/go/types/check.go:240 +0xfd
  golang.org/x/tools/go/loader.(*importer).newPackageInfo()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:1053 +0x836
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:961 +0xa4
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45

Goroutine 1882 (running) created at:
  golang.org/x/tools/go/loader.(*importer).startLoad()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:948 +0x329
  golang.org/x/tools/go/loader.(*importer).importAll()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45

Goroutine 1888 (finished) created at:
  golang.org/x/tools/go/loader.(*importer).startLoad()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:948 +0x329
  golang.org/x/tools/go/loader.(*importer).importAll()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (4.03s)
    testing.go:1465: race detected during execution of test
--- FAIL: TestLoad2 (4.14s)
    testing.go:1465: race detected during execution of test
FAIL
FAIL	golang.org/x/tools/go/loader	20.833s
@adonovan adonovan self-assigned this Jul 6, 2023
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 6, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 6, 2023
@findleyr
Copy link
Member

findleyr commented Jul 7, 2023

I'm seeing this flake with pretty high frequency as of yesterday, yet go/loader has not changed recently AFAIK.

A change to the race detector, perhaps?

@adonovan
Copy link
Member Author

adonovan commented Jul 7, 2023

Yeah, I had the same thought. But I can't reproduce it locally with 1.20, or tip, or tip from Jun 23. I just noticed that https://go.dev/cl/508437 is also failing in -race even though the change is benign. I've asked the runtime folks.

@findleyr
Copy link
Member

findleyr commented Jul 7, 2023

Possibly related: https://go.dev/cl/505055

@findleyr
Copy link
Member

findleyr commented Jul 7, 2023

This is actually resulting from https://go.dev/cl/507975, where NewChecker(...pkg...) was updated to mutate pkg.

As @prattmic pointed out in chat, importer.newPackageInfo calls NewChecker concurrently with types.Unsafe.

There are probably two bugs here: go/loader should not call NewChecker with types.Unsafe, but also we should probably not mutate pkg in NewChecker. Certainly the checker owns the package, but lets defer mutation until type-checking actually begins.

@adonovan
Copy link
Member Author

adonovan commented Jul 7, 2023

Well spotted. NewChecker should have an internal comment stating that it may be called with types.Unsafe, and that it should not mutate pkg until CheckFiles (which is never called for Unsafe). And CheckFiles should either return immediately or panic if pkg==Unsafe.

@findleyr
Copy link
Member

findleyr commented Jul 7, 2023

Yes, I'll fix.

@findleyr findleyr assigned findleyr and unassigned adonovan Jul 7, 2023
@findleyr findleyr modified the milestones: Unreleased, Go1.21 Jul 7, 2023
@findleyr findleyr changed the title x/tools/go/loader: data race in tests go/types: data races resulting from package mutation in NewChecker Jul 7, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/508439 mentions this issue: go/types, types2: do not mutate arguments in NewChecker

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/508440 mentions this issue: go/types, types2: document that NewChecker does not mutate its arguments

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- log ~ `WARNING: DATA RACE` && log ~ `\s+go/types\.NewChecker\(\)` && date < "2023-07-08"
2023-07-06 00:35 linux-arm64-race tools@e7916d01 go@b490bdc2 x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x3c8
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0xd8
  golang.org/x/tools/go/loader.(*importer).load()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x144
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x40
==================
--- FAIL: TestLoad2 (2.23s)
    testing.go:1465: race detected during execution of test
2023-07-06 00:35 linux-arm64-race tools@e7916d01 go@b490bdc2 x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (2.33s)
    testing.go:1465: race detected during execution of test
2023-07-06 19:23 linux-amd64-longtest-race tools@83045326 go@6305d7fd x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad2 (1.81s)
    testing.go:1465: race detected during execution of test
2023-07-06 19:23 linux-amd64-longtest-race tools@83045326 go@6305d7fd x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (1.96s)
    testing.go:1465: race detected during execution of test
2023-07-06 19:23 linux-amd64-race tools@83045326 go@449ef379 x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (4.51s)
    testing.go:1465: race detected during execution of test
2023-07-06 19:23 linux-amd64-race tools@83045326 go@449ef379 x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (4.53s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:34 linux-amd64-longtest-race tools@124ebfa4 go@449ef379 x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad2 (2.85s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:34 linux-amd64-longtest-race tools@124ebfa4 go@449ef379 x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (2.85s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:34 linux-amd64-race tools@124ebfa4 go@449ef379 x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (3.73s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:34 linux-amd64-race tools@124ebfa4 go@449ef379 x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (4.03s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:44 freebsd-amd64-race tools@eaca1d00 go@e6ec2a34 x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad2 (3.42s)
    testing.go:1465: race detected during execution of test
2023-07-06 20:44 freebsd-amd64-race tools@eaca1d00 go@e6ec2a34 x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (3.63s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:23 linux-amd64-longtest-race tools@4b177d0b go@e6ec2a34 x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad2 (2.55s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:23 linux-amd64-longtest-race tools@4b177d0b go@e6ec2a34 x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (2.58s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 freebsd-amd64-race tools@dfb7d247 go@e6ec2a34 x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (3.39s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 freebsd-amd64-race tools@dfb7d247 go@e6ec2a34 x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (3.40s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-longtest-race tools@dfb7d247 go@d3d78b4b x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (2.06s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-longtest-race tools@dfb7d247 go@d3d78b4b x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (2.19s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-longtest-race tools@dfb7d247 go@e6ec2a34 x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (2.57s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-longtest-race tools@dfb7d247 go@e6ec2a34 x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (2.58s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-race tools@dfb7d247 go@39c50707 x/tools/go/loader.TestLoad1 (log)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/workdir/go/src/nosuchpkg)
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x53d
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0x127
  golang.org/x/tools/go/loader.(*importer).load()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x199
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x45
==================
--- FAIL: TestLoad1 (2.59s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-amd64-race tools@dfb7d247 go@39c50707 x/tools/go/loader.TestLoad2 (log)
--- FAIL: TestLoad2 (2.73s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-arm64-race tools@dfb7d247 go@158d1119 x/tools/go/loader.TestLoad2 (log)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
package nosuchpkg is not in std (/tmp/workdir/go/src/nosuchpkg)
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
open /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/missing.go: no such file or directory
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/tmp/workdir/gopath/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
	/go/src/c (from $GOROOT)
	($GOPATH not set. For more details see: 'go help gopath'))
/go/src/b/x.go:1:21: could not import c (cannot find package "c" in any of:
...
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:897 +0x3c8
  golang.org/x/tools/go/loader.(*importer).addFiles()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:992 +0xd8
  golang.org/x/tools/go/loader.(*importer).load()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:968 +0x144
  golang.org/x/tools/go/loader.(*importer).startLoad.func1()
      /tmp/workdir/gopath/src/golang.org/x/tools/go/loader/loader.go:949 +0x40
==================
--- FAIL: TestLoad2 (2.06s)
    testing.go:1465: race detected during execution of test
2023-07-06 21:42 linux-arm64-race tools@dfb7d247 go@158d1119 x/tools/go/loader.TestLoad1 (log)
--- FAIL: TestLoad1 (2.20s)
    testing.go:1465: race detected during execution of test

watchflakes

bradfitz pushed a commit to tailscale/go that referenced this issue Jul 15, 2023
CL 507975 resulted in new data races (as reported in golang#61212), because
the pkg argument to NewChecker was mutated.

Fix this by deferring the recording of the goVersion in pkg until type
checking is actually initiated via a call to Checker.Files.
Additionally, modify types2/check.go to bring it in sync with the
changes in go/types/check.go, and generate the new version_test.go from
the types2 file.

Also move parsing the version into checkFiles, for simplicity.

Fixes golang#61212

Change-Id: I15edb6c2cff3085622fe7c6a3b0dab531d27bd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/508439
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
awly pushed a commit to tailscale/go that referenced this issue Feb 7, 2024
CL 507975 resulted in new data races (as reported in golang#61212), because
the pkg argument to NewChecker was mutated.

Fix this by deferring the recording of the goVersion in pkg until type
checking is actually initiated via a call to Checker.Files.
Additionally, modify types2/check.go to bring it in sync with the
changes in go/types/check.go, and generate the new version_test.go from
the types2 file.

Also move parsing the version into checkFiles, for simplicity.

Fixes golang#61212

Change-Id: I15edb6c2cff3085622fe7c6a3b0dab531d27bd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/508439
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
@golang golang locked and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Projects
Archived in project
Development

No branches or pull requests

3 participants