Title: reflect: Select panics if array length greater than 1<<16 · Issue #37350 · golang/go · GitHub
Open Graph Title: reflect: Select panics if array length greater than 1<<16 · Issue #37350 · golang/go
X Title: reflect: Select panics if array length greater than 1<<16 · Issue #37350 · golang/go
Description: What version of Go are you using (go version)? $ go version 1.13.7 Does this issue reproduce with the latest release? Yes, here is a go playground example What operating system and processor architecture are you using (go env)? go env Ou...
Open Graph Description: What version of Go are you using (go version)? $ go version 1.13.7 Does this issue reproduce with the latest release? Yes, here is a go playground example What operating system and processor archit...
X Description: What version of Go are you using (go version)? $ go version 1.13.7 Does this issue reproduce with the latest release? Yes, here is a go playground example What operating system and processor archit...
Opengraph URL: https://github.com/golang/go/issues/37350
X: @github
Domain: go.dev
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"reflect: Select panics if array length greater than 1\u003c\u003c16","articleBody":"### What version of Go are you using (`go version`)?\r\n\r\n\u003cpre\u003e\r\n$ go version\r\n1.13.7\r\n\u003c/pre\u003e\r\n\r\n### Does this issue reproduce with the latest release?\r\n\r\n[Yes, here is a go playground example](https://play.golang.org/p/88C_ON8hcrZ)\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n\r\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003ego env\u003c/code\u003e Output\u003c/summary\u003e\u003cbr\u003e\u003cpre\u003e\r\n$ go env\r\nGO111MODULE=\"\"\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/Users/milanpatel/Library/Caches/go-build\"\r\nGOENV=\"/Users/milanpatel/Library/Application Support/go/env\"\r\nGOEXE=\"\"\r\nGOFLAGS=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"darwin\"\r\nGONOPROXY=\"\"\r\nGONOSUMDB=\"\"\r\nGOOS=\"darwin\"\r\nGOPATH=\"/Users/milanpatel/go\"\r\nGOPRIVATE=\"\"\r\nGOPROXY=\"https://proxy.golang.org,direct\"\r\nGOROOT=\"/usr/local/Cellar/go/1.13.7/libexec\"\r\nGOSUMDB=\"sum.golang.org\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/usr/local/Cellar/go/1.13.7/libexec/pkg/tool/darwin_amd64\"\r\nGCCGO=\"gccgo\"\r\nAR=\"ar\"\r\nCC=\"clang\"\r\nCXX=\"clang++\"\r\nCGO_ENABLED=\"1\"\r\nGOMOD=\"\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gx/lcfzy_f56tlb_czrp7z2ptyc0000gn/T/go-build327901560=/tmp/go-build -gno-record-gcc-switches -fno-common\"\r\n\u003c/pre\u003e\u003c/details\u003e\r\n\r\n### What did you do?\r\n\r\nWe ran into an issue today where if the number of reflect cases in an array exceeds 1\u003c\u003c16, the call to `reflect.Select` panics. The function doc for the select implementation suggests that it's the length of the array that is used to recreate the pointer to the array, determined by a passed in variable `ncases`.\r\n\r\n```\r\n// selectgo implements the select statement.\r\n//\r\n// cas0 points to an array of type [ncases]scase, and order0 points to\r\n// an array of type [2*ncases]uint16. Both reside on the goroutine's\r\n// stack (regardless of any escaping in selectgo).\r\n//\r\n// selectgo returns the index of the chosen scase, which matches the\r\n// ordinal position of its respective select{recv,send,default} call.\r\n// Also, if the chosen scase was a receive operation, it reports whether\r\n// a value was received.\r\nfunc selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) {\r\n```\r\nIn fact, that doesn't appear to be true:\r\n```\r\n\tcas1 := (*[1 \u003c\u003c 16]scase)(unsafe.Pointer(cas0))\r\n\t...\r\n\tscases := cas1[:ncases:ncases] // \u003c- panics here \r\n```","author":{"url":"https://github.com/thempatel","@type":"Person","name":"thempatel"},"datePublished":"2020-02-21T02:53:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/37350/go/issues/37350"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3dbdd678-1a6d-9cb7-c4ef-e86c6b53c7ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7D2:34E071:1295C07:19B9673:6998B076 |
| html-safe-nonce | 3e59a898d9a9b9f39ec9499b6bb2a5f0fadb3636eb014c1df4c2ab86249a580c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0QyOjM0RTA3MToxMjk1QzA3OjE5Qjk2NzM6Njk5OEIwNzYiLCJ2aXNpdG9yX2lkIjoiMzgxMzA0Mzk3OTkxODE3MzM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3880ec4a22bd422005d45d78b533da442e62405ff04db70f029190bdb1387ad1 |
| hovercard-subject-tag | issue:568703801 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/golang/go/37350/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a7722262b62d22018643c7530391fddd091a0d3287f1147a7a5d8ba136b1254c/golang/go/issues/37350 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a7722262b62d22018643c7530391fddd091a0d3287f1147a7a5d8ba136b1254c/golang/go/issues/37350 |
| og:image:alt | What version of Go are you using (go version)? $ go version 1.13.7 Does this issue reproduce with the latest release? Yes, here is a go playground example What operating system and processor archit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thempatel |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72431d48abd9a2a5f97f6bae9dcb0d31dc185683b82bb625088ffe6e99af17e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/golang/go git https://github.com/golang/go.git |
| octolytics-dimension-user_id | 4314092 |
| octolytics-dimension-user_login | golang |
| octolytics-dimension-repository_id | 23096959 |
| octolytics-dimension-repository_nwo | golang/go |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 23096959 |
| octolytics-dimension-repository_network_root_nwo | golang/go |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fe6df8f2202abad7e4864b199d4819cb816b0863 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width