Skip to content

cmd/compile: Go 1.22 build fails with 1.21 PGO profile on internal/saferio change #65615

Closed

Description

@konradreiche

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

GOARCH='amd64'
GOOS='linux'
GOVERSION='go1.22.0'

What did you do?

We are continuously collecting PGO profiles and apply them to new builds, a process that worked seamlessly with Go 1.21. I upgraded to Go 1.22 and attempted to compile our build using the Go 1.21 PGO profile.

go build -pgo=auto .

What did you see happen?

The go build command failed, producing the following error:

go build -pgo=auto .
# encoding/gob
/usr/lib/go/src/bufio/bufio.go:47:6: internal compiler error: saferio.SliceCap has 0+1 params, but instantiated with 0+0 args

This error suggests a change made to the SliceCap method in the internal/saferio package between Go 1.21 and Go 1.22:

https://github.com/golang/go/blob/release-branch.go1.21/src/internal/saferio/io.go#L116
https://github.com/golang/go/blob/release-branch.go1.22/src/internal/saferio/io.go#L128

The build compiles successfully with PGO turned off:

go build -pgo=off .

What did you expect to see?

Expected the go build command to compile the build successfully, as it did with Go 1.21.

Activity

  1. konradreiche commented on Feb 8, 2024

    @konradreiche
    Author

    I assume this isn't expected because according to the PGO documentation a change to the source code could result in performance degradation but not necessarily compilation failure.

  2. prattmic commented on Feb 8, 2024

    @prattmic
    Member

    Thanks for filing this! We discovered this same crash with a different symbol independently this morning and I was coming to file an issue only to find you've done so for me. :D

    This is indeed a bug in the way we lookup functions for PGO. Internally, the compiler internally is trying to look up the function as non-generic (because the profile contains the non-generic symbol name), but the function is actually generic and the compiler chokes. We should fix this.

  3. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Feb 8, 2024
  4. added this to the Go1.23 milestone on Feb 8, 2024
  5. prattmic commented on Feb 8, 2024

    @prattmic
    Member

    @gopherbot Please backport to 1.21 and 1.22. This is a build failure with PGO if a hot function is changed from non-generic to generic. Only workarounds are to rename the symbol or disable PGO.

  6. gopherbot commented on Feb 8, 2024

    @gopherbot
    Contributor

    Backport issue(s) opened: #65617 (for 1.21), #65618 (for 1.22).

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

  7. gopherbot commented on Feb 8, 2024

    @gopherbot
    Contributor

    Change https://go.dev/cl/562737 mentions this issue: cmd/compile: fail noder.LookupFunc gracefully if function generic

  8. gopherbot commented on Feb 9, 2024

    @gopherbot
    Contributor

    Change https://go.dev/cl/563016 mentions this issue: [release-branch.go1.22] cmd/compile: fail noder.LookupFunc gracefully if function generic

  9. added a commit that references this issue on Feb 9, 2024
    532c6f1
  10. added a commit that references this issue on Feb 18, 2024
    00a1b89
  11. self-assigned this
    on Nov 15, 2024
  12. locked and limited conversation to collaborators on Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions