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 race in representableConst in Go 1.13 and earlier #36687

Closed
matloob opened this issue Jan 22, 2020 · 7 comments
Closed

go/types: data race in representableConst in Go 1.13 and earlier #36687

matloob opened this issue Jan 22, 2020 · 7 comments

Comments

@matloob
Copy link
Contributor

@matloob matloob commented Jan 22, 2020

The race in go/packages reported in #31749 was fixed at tip, but is still an issue for Go 1.13 and earlier, and is showing up in the go/packages race failure reported in #36605.

That race is caused by a race in go/types which in turn is caused by go/constant.Float64Val() calling Rat.Float64 in math/big, which has a race reported in #34919 , and subsequently fixed in tip.

Fixing this race in go/types on Go 1.13 and earlier requires backporting CL 201205 to those releases. (Alternatively, we could fix the race by adding a workaround in go/constant or go/types, but that would be more work). I'm not sure if fixing this is worth a backport but we might as well have the discussion. If we decide not to go with the backport, we'll have to accept a race in go/packages and disable some of its tests in race mode in Go 1.13 and earlier.

@matloob
Copy link
Contributor Author

@matloob matloob commented Jan 22, 2020

@gopherbot backport please 1.12 1.13

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 22, 2020

Backport issue(s) opened: #36688 (for 1.12), #36689 (for 1.13).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

Loading

@matloob
Copy link
Contributor Author

@matloob matloob commented Jan 22, 2020

Loading

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Jan 22, 2020

I can reproduce the data race in x/tools/go/packages on go1.13.6 darwin/amd64 fairly often by running go run -race . on:

package main

import "log"
import "golang.org/x/tools/go/packages"

func main() {
	for i := 0; i < 100; i++ {
		// Load, parse and type-check the program.
		cfg := &packages.Config{Mode: packages.LoadAllSyntax}
		pkgs, err := packages.Load(cfg, "std")
		if err != nil {
			log.Fatalf("failed to load metadata: %v", err)
		}
		if packages.PrintErrors(pkgs) > 0 {
			log.Fatalln("there were errors loading standard library")
		}
	}
}

However, it'd be nice to reduce this snippet to use go/types directly.

/cc @rsc and @griesemer who have worked on fixing the related problem in math/big for Go 1.14.

Loading

@bcmills
Copy link
Member

@bcmills bcmills commented Jan 22, 2020

I'm not sure if fixing this is worth a backport but we might as well have the discussion.

A data race in go/packages seems likely to translate to flakiness in gopls and similar tools. If we will support gopls on Go versions older than 1.14, then we should backport the fix for the data race.

(CC @ianthehat @stamblerre)

Loading

@stamblerre
Copy link

@stamblerre stamblerre commented Jan 22, 2020

gopls (as well as the rest of the tools repo) is supported for 2 Go versions behind the current release, so once Go 1.14 is out, we will still support 1.13 and 1.12. I'd support backporting a fix, though I'm not sure how much this has affected gopls.

Loading

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented May 11, 2020

This data race in go/types was resolved in Go 1.14 via a fix to the math/big package in CL 201205. I'll set the appropriate milestone and close this issue, because there's nothing actionable left here to do.

This fix is being considered for backporting to Go 1.13.x in issue #36689.

Loading

@dmitshur dmitshur closed this May 11, 2020
@golang golang locked and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants