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

reflect.Select: behavior when called with an empty slice of cases #22733

Closed
AndreyNevolin opened this issue Nov 15, 2017 · 2 comments
Closed

Comments

@AndreyNevolin
Copy link

Please answer these questions before submitting your issue. Thanks!

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

1.9.1

Does this issue reproduce with the latest release?

Don't know

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

GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

active_index, rcv_value, ok := reflect.Select(make([]reflect.SelectCase, 0))

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
package main

import "reflect"
import "fmt"

func main() {
active_index, rcv_value, ok := reflect.Select(make([]reflect.SelectCase, 0))
fmt.Println(active_index, rcv_value, ok)
}

What did you expect to see?

I don't know. The behavior of "reflect.Select" called with an empty slice is not documented anywhere as I can judge.
I would prefer the call to return an error. But I don't know what is the intended behavior. Maybe the developers consider "hanging forever" behavior the right option.

Please consider changing or documenting the behavior of "reflect.Select" called with an empty slice.

What did you see instead?

The following message:
fatal error: all goroutines are asleep - deadlock!

@ghost
Copy link

ghost commented Nov 15, 2017

This is documented in the reflect.Select call:

Like the Go select statement, it blocks until at least one of the cases can proceed

Since there are no cases, it blocks forever. You get the same result when doing the following:

select {}

@ianlancetaylor
Copy link
Contributor

The intent is that reflect.Select act like the select statement. I think that is what it does, and it is documented that way. Closing because I don't think there is anything to do.

@golang golang locked and limited conversation to collaborators Nov 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants