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
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@matloob
Copy link
Contributor

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 commented Jan 22, 2020

@gopherbot backport please 1.12 1.13

@gopherbot
Copy link
Contributor

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.

@matloob
Copy link
Contributor Author

matloob commented Jan 22, 2020

cc @dmitshur

@dmitshur dmitshur added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 22, 2020
@dmitshur
Copy link
Contributor

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.

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jan 22, 2020
@bcmills
Copy link
Contributor

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)

@stamblerre
Copy link
Contributor

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.

@dmitshur dmitshur modified the milestones: Go1.13, Go1.14 May 11, 2020
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 11, 2020
@dmitshur
Copy link
Contributor

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.

@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.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants