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

x/xerrors: Uncomparable error type causes runtime panic #31841

Closed
darkfeline opened this issue May 5, 2019 · 2 comments
Closed

x/xerrors: Uncomparable error type causes runtime panic #31841

darkfeline opened this issue May 5, 2019 · 2 comments
Milestone

Comments

@darkfeline
Copy link
Contributor

@darkfeline darkfeline commented May 5, 2019

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

golang.org/x/xerrors@v0.0.0-20190410155217-1f06c39b4373

Does this issue reproduce with the latest release?

Yes

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

env agnostic

What did you do?

package main

import (
	"fmt"

	"golang.org/x/xerrors"
)

type myErr struct {
	foo []string // uncomparable
}

func (myErr) Error() string {
	return "error"
}

func (myErr) Is(target error) bool {
	return true
}

func main() {
	if xerrors.Is(myErr{}, myErr{}) {
		fmt.Println("foo")
	}
	fmt.Println("bar")
}

What did you expect to see?

No runtime error

What did you see instead?

panic: runtime error: comparing uncomparable type main.myErr

goroutine 1 [running]:
golang.org/x/xerrors.Is(0x4d1200, 0xc00000c080, 0x4d1200, 0xc00000c0a0, 0xc000032728)
	~/go/pkg/mod/golang.org/x/xerrors@v0.0.0-20190410155217-1f06c39b4373/wrap.go:55 +0x141
main.main()
	/tmp/mod/main.go:22 +0xb7
@gopherbot gopherbot added this to the Unreleased milestone May 5, 2019
@gopherbot
Copy link

@gopherbot gopherbot commented May 5, 2019

Change https://golang.org/cl/175260 mentions this issue: errors: fix Is panic if passing uncomparable type

@gopherbot
Copy link

@gopherbot gopherbot commented May 5, 2019

Change https://golang.org/cl/174980 mentions this issue: xerrors: fix Is panic if passing uncomparable type

@gopherbot gopherbot closed this in 0bf1f02 May 6, 2019
gopherbot pushed a commit to golang/xerrors that referenced this issue May 6, 2019
Analogous change to golang.org/cl/175260

Fixes golang/go#31841

Change-Id: I93bf093e8d5c13269fe7164a3a1b6956450998e5
Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/174980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators May 5, 2020
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
2 participants
You can’t perform that action at this time.