Skip to content

cmd/compile: internal compiler error: assertion failed #54135

Closed

Description

@r-hang

What version of Go are you using (go version)?

master
$ go version
go version devel go1.19-5c8ec89cb5 Thu Jul 28 21:13:04 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Fails on both go1.19rc2 and master. Passes on go1.18.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go-code2/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go-code2"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org/,direct"
GOROOT="/home/user/go/src/github.com/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/go/src/github.com/golang/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-5c8ec89cb5 Thu Jul 28 21:13:04 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3108614045=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Try compiling this test program

package main

import (
	"fmt"
	"testing"
)

type Bar[T any] interface{
    Blanker()
}

type FooBar[T any] interface{}

type Foo[E comparable] struct {
	me E
}

func (b *Foo[E]) do(h Bar[E], f FooBar[E]) {
	check(h, f)
}

func check[T comparable](p Bar[T], q FooBar[T]) int {
	if _, ok := p.(Checkable); ok {
		fmt.Println(ok)
	}
	if _, ok := q.(Checkable); ok {
		fmt.Println(ok)
	}
	return 1
}

type Checkable interface{}

func TestFunction(m *testing.T) {
	x := Foo[int]{me: 2}
	fmt.Println(x)
}

What did you expect to see?

Test passed.

What did you see instead?

./main_test.go:19:7: internal compiler error: assertion failed

Activity

  1. changed the title [-]affected/package: cmd/compile go1.19 Fails to build generic program[/-] [+]cmd/compile go1.19 Fails to build generic program[/+] on Jul 29, 2022
  2. sywhang commented on Jul 29, 2022

    @sywhang
    Contributor

    To add a bit of context, we found this issue while testing Go 1.19 on our Go Monorepo at Uber. We noticed both master and 1.19 rc2 is breaking with some of the latest changes in our codebase that made use of generics.

    The program above is a small repro we were able to isolate out of the actual code that broke.

  3. ianlancetaylor commented on Jul 29, 2022

    @ianlancetaylor
    Contributor

    May be a dup of #53762.

  4. sywhang commented on Jul 29, 2022

    @sywhang
    Contributor

    @ianlancetaylor thanks, i can confirm the failure is coming from the same place as #53762.

    The repro program we posted above should help debugging the root cause.

  5. ianlancetaylor commented on Jul 29, 2022

    @ianlancetaylor
    Contributor

    Thanks, closing as a dup. My understanding is that #53762 has already been fixed on tip.

  6. sywhang commented on Jul 29, 2022

    @sywhang
    Contributor

    @ianlancetaylor Sorry, but I don't think it has been. The program above still fails to build on tip. The latest comments in #53762 seems like there are others facing the same issue on tip.

    > Will you re-open this issue or should I create a new one?

  7. changed the title [-]cmd/compile go1.19 Fails to build generic program[/-] [+]cmd/compile: internal compiler error: assertion failed[/+] on Jul 29, 2022
  8. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Jul 29, 2022
  9. added this to the Go1.19 milestone on Jul 30, 2022
  10. ianlancetaylor commented on Jul 30, 2022

    @ianlancetaylor
    Contributor

    You're right, it's still crashing. Sorry about that.

    CC @randall77 @mdempsky

  11. gopherbot commented on Jul 31, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/420394 mentions this issue: cmd/compile: fix wrong dict pass condition for type assertions

  12. sywhang commented on Jul 31, 2022

    @sywhang
    Contributor

    Tested the fix above, and it still is failing to build some generics code. I will follow up with a repro shortly.

  13. 1 remaining item

  14. gopherbot commented on Aug 1, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/420421 mentions this issue: test: improve generic type assertion test

  15. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    and removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Aug 1, 2022
  16. sywhang commented on Aug 1, 2022

    @sywhang
    Contributor

    Can this fix be cherry-picked to Go 1.19 branch before the release tomorrow? Plenty of code out there will be blocked on upgrading to 1.19 until this fix is made available.

  17. gopherbot commented on Aug 1, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/420675 mentions this issue: [release-branch.go1.19] test: improve generic type assertion test

  18. gopherbot commented on Aug 1, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/420674 mentions this issue: [release-branch.go1.19] cmd/compile: fix wrong dict pass condition for type assertions

  19. added 2 commits that reference this issue on Aug 10, 2022
    b9e478b
    53f8e9b
  20. locked and limited conversation to collaborators on Aug 1, 2023
  21. added a commit that references this issue on Feb 10, 2024
    27038b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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