{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/17752","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/17752/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/17752/comments","events_url":"https://api.github.com/repos/golang/go/issues/17752/events","html_url":"https://github.com/golang/go/issues/17752","id":186938124,"number":17752,"title":"cmd/compile: invalid algorithm table for some types","user":{"login":"randall77","id":6889504,"avatar_url":"https://avatars.githubusercontent.com/u/6889504?v=3","gravatar_id":"","url":"https://api.github.com/users/randall77","html_url":"https://github.com/randall77","followers_url":"https://api.github.com/users/randall77/followers","following_url":"https://api.github.com/users/randall77/following{/other_user}","gists_url":"https://api.github.com/users/randall77/gists{/gist_id}","starred_url":"https://api.github.com/users/randall77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randall77/subscriptions","organizations_url":"https://api.github.com/users/randall77/orgs","repos_url":"https://api.github.com/users/randall77/repos","events_url":"https://api.github.com/users/randall77/events{/privacy}","received_events_url":"https://api.github.com/users/randall77/received_events","type":"User","site_admin":false},"labels":[{"id":373399998,"url":"https://api.github.com/repos/golang/go/labels/NeedsFix","name":"NeedsFix","color":"ededed","default":false}],"state":"open","locked":false,"assignee":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"assignees":[{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/38","html_url":"https://github.com/golang/go/milestones/Go1.8","labels_url":"https://api.github.com/repos/golang/go/milestones/38/labels","id":1709363,"number":38,"title":"Go1.8","description":"","creator":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"open_issues":140,"closed_issues":552,"state":"open","created_at":"2016-04-15T16:30:23Z","updated_at":"2016-11-03T18:20:10Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"comments":6,"created_at":"2016-11-02T22:33:19Z","updated_at":"2016-11-03T21:10:46Z","closed_at":null,"body":"```\r\npackage main\r\n\r\nfunc f(m map[string]int) int {\r\n\treturn m[\"a\"]\r\n}\r\n\r\nfunc g(m map[[8]string]int) int {\r\n\treturn m[[8]string{\"a\", \"a\", \"a\", \"a\", \"a\", \"a\", \"a\", \"a\"}]\r\n}\r\n\r\nfunc main() {\r\n\tm := map[[8]string]int{}\r\n\tprintln(g(m))\r\n}\r\n```\r\n\r\nWith `f` commented out, the example program runs fine (prints `0`) in all versions of Go I tested.\r\n\r\nWith `f` not commented out, I get behavior all over the map.\r\n1.2, 1.4: integer divide by zero panic\r\n1.5, 1.6: success!\r\n1.7, tip: fatal error: runtime.makemap: unsupported map key type\r\n\r\nThe failures at 1.7 & tip are the result of explicit checks; the code barfs because the key does not have a hash algorithm.\r\n\r\nI suspect the problem is that during compilation of `f`, we construct a type `[8]string` as part of the map bucket.  That type is marked as not needing an algorithm table.  Later, when compiling `g`, we construct a map with key type `[8]string` and that type does need an algorithm table.  Maybe the former decision is overriding the latter?\r\n\r\n@dsnet @dr2chase @crawshaw @josharian "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/258275084","html_url":"https://github.com/golang/go/issues/17752#issuecomment-258275084","issue_url":"https://api.github.com/repos/golang/go/issues/17752","id":258275084,"user":{"login":"mdempsky","id":38349,"avatar_url":"https://avatars.githubusercontent.com/u/38349?v=3","gravatar_id":"","url":"https://api.github.com/users/mdempsky","html_url":"https://github.com/mdempsky","followers_url":"https://api.github.com/users/mdempsky/followers","following_url":"https://api.github.com/users/mdempsky/following{/other_user}","gists_url":"https://api.github.com/users/mdempsky/gists{/gist_id}","starred_url":"https://api.github.com/users/mdempsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdempsky/subscriptions","organizations_url":"https://api.github.com/users/mdempsky/orgs","repos_url":"https://api.github.com/users/mdempsky/repos","events_url":"https://api.github.com/users/mdempsky/events{/privacy}","received_events_url":"https://api.github.com/users/mdempsky/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T21:10:46Z","updated_at":"2016-11-03T21:10:46Z","body":"@josharian No, I'm happy to dig into this.\r\n\r\nSo the issue is when we're writing out reflect metadata for types, we use the same link symbol regardless of whether Noalg is set, but we generate different contents depending on Noalg (namely whether we provide hash/eq function pointers).  The consequence is everywhere we set Noalg on compiler-generated types, we're potentially poisoning any user types that happen to be identical.\r\n\r\nIt's just that the types we set Noalg on are rarely used as map keys or stored into interfaces and compared for equality, assuming they collide at all.  Aside from the bucket arrays discovered above, the other instances are all structs (and one slice, but Noalg is redundant on slices anyway).\r\n\r\nI think making Noalg work 100% correctly requires linker support.  We probably need to generate separate symbols for the Noalg variants.  Later at link-time we could recognize if we have both Noalg and !Noalg variants, and use only the !Noalg variant.\r\n\r\nIn the mean time, I think the quick fix is to just not set Noalg on the bucket arrays.  I'll send a CL."}}
{"actor":{"display_login":"mdempsky"}}