Skip to content

x/tools/go/analysis/unitchecker: TestExampleSeparateAnalysis failing to produce printf diagnostics #68744

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

Closed
gopherbot opened this issue Aug 6, 2024 · 17 comments
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@gopherbot
Copy link
Contributor

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"

Issue created automatically to collect these failures.

Example (log):

=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (264.32s)

watchflakes

@gopherbot gopherbot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 6, 2024
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-05 17:36 x_tools-gotip-darwin-amd64-longtest tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (264.32s)
2024-08-05 17:36 x_tools-gotip-linux-386-longtest tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (76.05s)
2024-08-05 17:36 x_tools-gotip-linux-amd64-longtest tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (73.43s)
2024-08-05 17:36 x_tools-gotip-linux-amd64-longtest-race tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (130.38s)
2024-08-05 17:36 x_tools-gotip-linux-arm64-longtest tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (89.33s)
2024-08-05 17:36 x_tools-gotip-windows-amd64-longtest tools@a5df6ad5 go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ..\..\..\..\goroot\src\os\os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ..\..\..\..\goroot\src\os\os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (59.51s)
2024-08-05 18:02 x_tools-gotip-darwin-amd64-longtest tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (273.38s)
2024-08-05 18:02 x_tools-gotip-linux-386-longtest tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (77.62s)
2024-08-05 18:02 x_tools-gotip-linux-amd64-longtest tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (73.22s)
2024-08-05 18:02 x_tools-gotip-linux-amd64-longtest-race tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (112.18s)
2024-08-05 18:02 x_tools-gotip-linux-arm64-longtest tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (95.73s)
2024-08-05 18:02 x_tools-gotip-windows-amd64-longtest tools@3ffd605b go@d465aee0 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ..\..\..\..\goroot\src\os\os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ..\..\..\..\goroot\src\os\os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (57.04s)
2024-08-05 18:50 x_tools-gotip-darwin-amd64-longtest tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (277.87s)
2024-08-05 18:50 x_tools-gotip-linux-386-longtest tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (73.57s)
2024-08-05 18:50 x_tools-gotip-linux-amd64-longtest tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (69.63s)
2024-08-05 18:50 x_tools-gotip-linux-amd64-longtest-race tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (119.85s)
2024-08-05 18:50 x_tools-gotip-linux-arm64-longtest tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (92.36s)
2024-08-05 18:50 x_tools-gotip-windows-amd64-longtest tools@f855a539 go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ..\..\..\..\goroot\src\os\os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ..\..\..\..\goroot\src\os\os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (84.81s)
2024-08-06 13:34 x_tools-gotip-darwin-amd64-longtest tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (274.58s)
2024-08-06 13:34 x_tools-gotip-linux-386-longtest tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (78.13s)
2024-08-06 13:34 x_tools-gotip-linux-amd64-longtest tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (72.39s)
2024-08-06 13:34 x_tools-gotip-linux-amd64-longtest-race tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (116.27s)
2024-08-06 13:34 x_tools-gotip-linux-arm64-longtest tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (90.03s)
2024-08-06 13:34 x_tools-gotip-windows-amd64-longtest tools@4653e48e go@1f0c044d x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ..\..\..\..\goroot\src\os\os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ..\..\..\..\goroot\src\os\os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (72.00s)

watchflakes

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Aug 6, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 6, 2024
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-06 13:34 x_tools-gotip-linux-386-longtest tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (80.15s)
2024-08-06 13:34 x_tools-gotip-linux-amd64-longtest tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (70.72s)
2024-08-06 13:34 x_tools-gotip-linux-amd64-longtest-race tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (121.26s)
2024-08-06 13:34 x_tools-gotip-linux-arm64-longtest tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (92.48s)
2024-08-06 13:34 x_tools-gotip-windows-amd64-longtest tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ..\..\..\..\goroot\src\os\os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ..\..\..\..\goroot\src\os\os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (70.07s)

watchflakes

@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/603515 mentions this issue: os: change t.Errorf call to t.Error in unit test

@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-06 13:34 x_tools-gotip-darwin-amd64-longtest tools@4653e48e go@b915399e x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (469.16s)

watchflakes

@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-06 13:34 x_tools-gotip-darwin-amd64-longtest tools@4653e48e go@abc3d2c1 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (254.21s)

watchflakes

@gopherbot gopherbot reopened this Aug 7, 2024
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-06 19:12 x_tools-gotip-darwin-amd64-longtest tools@3057be8f go@a7c7ec59 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (385.95s)

watchflakes

@github-project-automation github-project-automation bot moved this from Done to Active in Test Flakes Aug 7, 2024
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-08-06 19:12 x_tools-gotip-darwin-amd64-longtest tools@3057be8f go@0ea534b8 x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # os_test
        # [os_test]
        ../../../../goroot/src/os/os_test.go:1536:14: non-constant format string in call to (*testing.common).Errorf
        ../../../../goroot/src/os/os_test.go:1539:13: non-constant format string in call to (*testing.common).Errorf
--- FAIL: TestVetStdlib (127.94s)

watchflakes

@adonovan adonovan self-assigned this Aug 7, 2024
@adonovan
Copy link
Member

adonovan commented Aug 7, 2024

The original failure ("non-constant format string") was fixed by https://go.dev/cl/603515 (thanks @timothy-king), but I'm seeing a second failure with goroot and x/tools both at tip:

xtools$ go test ./go/analysis/unitchecker
--- FAIL: TestExampleSeparateAnalysis (1.78s)
...
    separate_test.go:228: Got: 
        Want: /main/main.go:6:2: [printf] separate/lib.MyPrintf format %s has arg 123 of wrong type int
FAIL
FAIL	golang.org/x/tools/go/analysis/unitchecker	11.954s
FAIL

In other words, the separate-analysis test is failing to produce the expected printf diagnostics. Will investigate...

@adonovan adonovan changed the title x/tools/go/analysis/unitchecker: TestVetStdlib failures [consistent failure] x/tools/go/analysis/unitchecker: TestExampleSeparateAnalysis failing to produce printf diagnostics Aug 7, 2024
@adonovan
Copy link
Member

adonovan commented Aug 8, 2024

GOWORK=off is an effective workaround, and this explains why the problem never showed up on the builders, even though it affects my and @findleyr's development environments, and is fully deterministic:

--- FAIL: TestExampleSeparateAnalysis (1.06s)
...
    separate_test.go:228: Got: 
        Want: /main/main.go:6:2: [printf] separate/lib.MyPrintf format %s has arg 123 of wrong type int
FAIL
FAIL	golang.org/x/tools/go/analysis/unitchecker	6.576s
FAIL
xtools$ GOWORK=off go test -count=1 ./go/analysis/unitchecker/
ok  	golang.org/x/tools/go/analysis/unitchecker	6.136s

Still investigating...

@adonovan
Copy link
Member

adonovan commented Aug 8, 2024

Setting GOWORK=off within the test has no effect, so it's the effect of the go.work file on the build of the test executable that matters. Bisecting reveals that it's the go 1.23rc2 (or rc1) directive in the go.work file that has the effect: even when using an rc2 toolchain, this directive causes the test to fail. That means the language-version tags are being affected. So, something in the test depends on the go1.23 language tag. Knowing a little about the test, the only thing I can think of is GODEBUG=gotypesalias. This was a lucky guess: setting this explicitly to 0 causes the test to pass.

So, the presence of a go.work file on a workstation (but not the builder) causes the tests to use go1.23 semantics, including language-version build tags, which may change the default value of a GODEBUG. This is working as intended. But gotypesalias=1 appears to have a bug that somehow affects this test. This bug may be a possible go1.23 release-blocker.

xtools$ GOWORK=off GODEBUG=gotypesalias=1 go test -count=1 -v ./go/analysis/unitchecker/ -run=Sep
=== RUN   TestExampleSeparateAnalysis
    separate_test.go:228: Got: 
        Want: /main/main.go:6:2: [printf] separate/lib.MyPrintf format %s has arg 123 of wrong type int
--- FAIL: TestExampleSeparateAnalysis (1.35s)
FAIL
FAIL	golang.org/x/tools/go/analysis/unitchecker	1.730s
FAIL

xtools$ GOWORK=off GODEBUG=gotypesalias=0 go test -count=1 -v ./go/analysis/unitchecker/ -run=Sep
--- PASS: TestExampleSeparateAnalysis (1.10s)
PASS
ok  	golang.org/x/tools/go/analysis/unitchecker	1.502s

Thanks @matloob and @samthanawalla.

@adonovan
Copy link
Member

adonovan commented Aug 8, 2024

Another lucky guess: this patch to go/types is an effective workaround. (The only alias I could see in the source was any in the Printf signature.)

	{
		universeAnyNoAlias = NewTypeName(nopos, nil, "any", &Interface{complete: true, tset: &topTypeSet})
		universeAnyNoAlias.setColor(black)
		// ensure that the any TypeName reports a consistent Parent, after
		// hijacking Universe.Lookup with gotypesalias=0.
		universeAnyNoAlias.setParent(Universe)

		// It shouldn't matter which representation of any is actually inserted
		// into the Universe, but we lean toward the future and insert the Alias
		// representation.
		universeAnyAlias = NewTypeName(nopos, nil, "any", nil)
		universeAnyAlias.setColor(black)
		_ = NewAlias(universeAnyAlias, universeAnyNoAlias.Type().Underlying()) // Link TypeName and Alias
-		def(universeAnyAlias)
+		def(universeAnyNoAlias)
	}

@adonovan
Copy link
Member

adonovan commented Aug 8, 2024

The problem is that the printf analyzer assumes that the type of the final args ...interface{} parameter of every printf wrapper is represented as *types.Interface, which is true when the syntax is an explicit interface{} type literal, or when
we referenced the old value of types.Universe.Lookup("any"), but not when any is represented as a materialized alias.
So this is the fix:

--- a/go/analysis/passes/printf/printf.go
+++ b/go/analysis/passes/printf/printf.go
@@ -160,9 +160,8 @@ func maybePrintfWrapper(info *types.Info, decl ast.Decl) *printfWrapper {
        nparams := params.Len() // variadic => nonzero
 
        args := params.At(nparams - 1)
-       iface, ok := args.Type().(*types.Slice).Elem().(*types.Interface)
-       if !ok || !iface.Empty() {
-               return nil // final (args) param is not ...interface{}
+       if !types.Identical(args.Type().(*types.Slice).Elem(), types.Universe.Lookup("any").Type()) {
+               return nil // final param (args) is not "...interface{}"
        }
 

This somehow slipped through my audit for places that do types.Type type assertions/switches that might depend on materialized aliases.

@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/603938 mentions this issue: go/analysis/passes/printf: add missing Unalias call

gopherbot pushed a commit to golang/tools that referenced this issue Aug 8, 2024
The maybePrintfWrapper function checks to see that a function
has the form of a printf wrapper, but it wrongly assumed that
the representation of the type of the "args ...any" parameter
is exactly interface{}, not a named alias. This will not work
with gotypesalias=1.

Unfortunately our CL system failed to report this (or indeed
any gotypesalias=1 coverage at all) because of a bug in the
Go bootstrapping process that, in the absence of a go.work file
(which sets the language version to go1.23), the default values
of the GODEBUG table were based on an older version of Go.
(The problem was only noticed when running a test of unitchecker
locally in the context of issue 68796.)

Also, the problem wasn't caught by our existing tests of the
printf checker because they all pre-date "any", and so spelled
it "interface{}".

This CL will need to be vendored into the go1.23 release.

Updates golang/go#68744
Updates golang/go#68796

Change-Id: I834ea20c2a684ffcd7ce9494d3700371ae6ab3c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603938
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
@gopherbot
Copy link
Contributor Author

Change https://go.dev/cl/609435 mentions this issue: [gopls-release-branch.0.16] go/analysis/passes/printf: add missing Unalias call

gopherbot pushed a commit to golang/tools that referenced this issue Aug 29, 2024
…alias call

The maybePrintfWrapper function checks to see that a function
has the form of a printf wrapper, but it wrongly assumed that
the representation of the type of the "args ...any" parameter
is exactly interface{}, not a named alias. This will not work
with gotypesalias=1.

Unfortunately our CL system failed to report this (or indeed
any gotypesalias=1 coverage at all) because of a bug in the
Go bootstrapping process that, in the absence of a go.work file
(which sets the language version to go1.23), the default values
of the GODEBUG table were based on an older version of Go.
(The problem was only noticed when running a test of unitchecker
locally in the context of issue 68796.)

Also, the problem wasn't caught by our existing tests of the
printf checker because they all pre-date "any", and so spelled
it "interface{}".

This CL will need to be vendored into the go1.23 release.

Updates golang/go#68744
Updates golang/go#68796

Change-Id: I834ea20c2a684ffcd7ce9494d3700371ae6ab3c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603938
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 28ba991)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609435
TryBot-Bypass: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-11-15 16:15 x_tools-gotip-linux-386-longtest tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (83.58s)
2024-11-15 16:15 x_tools-gotip-linux-amd64-longtest tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (70.54s)
2024-11-15 16:15 x_tools-gotip-linux-amd64-longtest-aliastypeparams tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (75.04s)
2024-11-15 16:15 x_tools-gotip-linux-amd64-longtest-race tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (126.77s)
2024-11-15 16:15 x_tools-gotip-linux-arm64-longtest tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (95.00s)

watchflakes

@gopherbot
Copy link
Contributor Author

Found new dashboard test flakes for:

#!watchflakes
default <- pkg == "golang.org/x/tools/go/analysis/unitchecker" && test == "TestVetStdlib"
2024-11-15 16:15 x_tools-gotip-darwin-amd64-longtest tools@56ec1110 go@fd050b3c x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ../../../../goroot/src/crypto/internal/fips/check/check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (319.73s)
2024-11-15 16:15 x_tools-gotip-windows-amd64-longtest tools@56ec1110 go@400433af x/tools/go/analysis/unitchecker.TestVetStdlib (log)
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # crypto/internal/fips/check
        # [crypto/internal/fips/check]
        ..\..\..\..\goroot\src\crypto\internal\fips\check\check.go:89:3: unreachable code
--- FAIL: TestVetStdlib (60.94s)

watchflakes

@adonovan
Copy link
Member

Most recent TestVetStdlib failures indicated a real problem, fixed by CL 628555.

@adonovan adonovan closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2024
@github-project-automation github-project-automation bot moved this from Active to Done in Test Flakes Nov 17, 2024
@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 Nov 17, 2024
@dmitshur dmitshur removed this from Test Flakes Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants