{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/14904","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/14904/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/14904/comments","events_url":"https://api.github.com/repos/golang/go/issues/14904/events","html_url":"https://github.com/golang/go/issues/14904","id":142534181,"number":14904,"title":"runtime: fault in runtime.mapiternext","user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/31","html_url":"https://github.com/golang/go/milestones/Go1.7","labels_url":"https://api.github.com/repos/golang/go/milestones/31/labels","id":1414133,"number":31,"title":"Go1.7","description":"","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":279,"closed_issues":132,"state":"open","created_at":"2015-11-16T16:57:07Z","updated_at":"2016-03-24T02:30:45Z","due_on":"2016-07-31T07:00:00Z","closed_at":null},"comments":8,"created_at":"2016-03-22T03:15:07Z","updated_at":"2016-03-24T05:07:41Z","closed_at":null,"body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n1. What version of Go are you using (`go version`)?\r\n\r\ngo linux/amd64, rev d4663e13536d7d43666e53ae21114008cb65d790\r\n\r\n2. What operating system and processor architecture are you using (`go env`)?\r\n\r\nlinux/amd64\r\n\r\n3. What did you do?\r\n\r\n     cd $GOPATH/src/github.com/juju/juju/cmd/juju/status\r\n     go test -i -v . && go test -count=20\r\n\r\nUnfortunately reproducing this bug requires our monstrous test suite. For those who want to reproduce the issue I can setup a AWS instance with the correct dependencies.\r\n\r\n4. What did you expect to see?\r\n\r\ntests pass\r\n\r\n5. What did you see instead?\r\n```\r\nunexpected fault address 0x0\r\nfatal error: fault\r\n[signal 0xb code=0x80 addr=0x0 pc=0x409722]\r\n\r\ngoroutine 610 [running]:\r\nruntime.throw(0x12fdcfb, 0x5)\r\n\t/home/dfc/go/src/runtime/panic.go:566 +0x8c fp=0xc820aed2a8 sp=0xc820aed290\r\nruntime.sigpanic()\r\n\t/home/dfc/go/src/runtime/sigpanic_unix.go:27 +0x27d fp=0xc820aed2f8 sp=0xc820aed2a8\r\nruntime.mapiternext(0xc8206ae4e0)\r\n\t/home/dfc/go/src/runtime/hashmap.go:718 +0xc2 fp=0xc820aed390 sp=0xc820aed2f8\r\nruntime.mapiterinit(0x1064940, 0xc820297980, 0xc8206ae4e0)\r\n\t/home/dfc/go/src/runtime/hashmap.go:666 +0x1bf fp=0xc820aed3c8 sp=0xc820aed390\r\nreflect.mapiterinit(0x1064940, 0xc820297980, 0x95)\r\n\t/home/dfc/go/src/runtime/hashmap.go:1014 +0x4a fp=0xc820aed3f0 sp=0xc820aed3c8\r\nreflect.Value.MapKeys(0x1064940, 0xc820ac8398, 0x95, 0x0, 0x0, 0x45c)\r\n\t/home/dfc/go/src/reflect/value.go:1074 +0xb1 fp=0xc820aed490 sp=0xc820aed3f0\r\nencoding/json.(*mapEncoder).encode(0xc820252330, 0xc82020e0b0, 0x1064940, 0xc820ac8398, 0x95, 0x400)\r\n\t/home/dfc/go/src/encoding/json/encode.go:614 +0x9a fp=0xc820aed530 sp=0xc820aed490\r\nencoding/json.(*mapEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x1064940, 0xc820ac8398, 0x95, 0x0)\r\n\t/home/dfc/go/src/encoding/json/encode.go:632 +0x51 fp=0xc820aed568 sp=0xc820aed530\r\nencoding/json.(*structEncoder).encode(0xc8202f02a0, 0xc82020e0b0, 0x1203a80, 0xc820ac8360, 0x99, 0xc820ac8300)\r\n\t/home/dfc/go/src/encoding/json/encode.go:587 +0x230 fp=0xc820aed6d0 sp=0xc820aed568\r\nencoding/json.(*structEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x1203a80, 0xc820ac8360, 0x99, 0xc82038cb00)\r\n\t/home/dfc/go/src/encoding/json/encode.go:601 +0x51 fp=0xc820aed708 sp=0xc820aed6d0\r\nencoding/json.(*mapEncoder).encode(0xc8202523d8, 0xc82020e0b0, 0x1065240, 0xc82017b948, 0x95, 0x200)\r\n\t/home/dfc/go/src/encoding/json/encode.go:622 +0x245 fp=0xc820aed7a8 sp=0xc820aed708\r\nencoding/json.(*mapEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x1065240, 0xc82017b948, 0x95, 0x0)\r\n\t/home/dfc/go/src/encoding/json/encode.go:632 +0x51 fp=0xc820aed7e0 sp=0xc820aed7a8\r\nencoding/json.(*structEncoder).encode(0xc8205fdef0, 0xc82020e0b0, 0x1194940, 0xc82017b920, 0x99, 0x1194900)\r\n\t/home/dfc/go/src/encoding/json/encode.go:587 +0x230 fp=0xc820aed948 sp=0xc820aed7e0\r\nencoding/json.(*structEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x1194940, 0xc82017b920, 0x99, 0xc82017b900)\r\n\t/home/dfc/go/src/encoding/json/encode.go:601 +0x51 fp=0xc820aed980 sp=0xc820aed948\r\nencoding/json.(*encodeState).reflectValue(0xc82020e0b0, 0x1194940, 0xc82017b920, 0x99)\r\n\t/home/dfc/go/src/encoding/json/encode.go:301 +0x6e fp=0xc820aed9b0 sp=0xc820aed980\r\nencoding/json.interfaceEncoder(0xc82020e0b0, 0x10358a0, 0xc8206e83f0, 0x194, 0x0)\r\n\t/home/dfc/go/src/encoding/json/encode.go:560 +0xba fp=0xc820aed9e8 sp=0xc820aed9b0\r\nencoding/json.(*structEncoder).encode(0xc8203df0e0, 0xc82020e0b0, 0x11efda0, 0xc8206e8380, 0x199, 0x0)\r\n\t/home/dfc/go/src/encoding/json/encode.go:587 +0x230 fp=0xc820aedb50 sp=0xc820aed9e8\r\nencoding/json.(*structEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x11efda0, 0xc8206e8380, 0x199, 0xc8206e8300)\r\n\t/home/dfc/go/src/encoding/json/encode.go:601 +0x51 fp=0xc820aedb88 sp=0xc820aedb50\r\nencoding/json.(*ptrEncoder).encode(0xc8204a2100, 0xc82020e0b0, 0x1082b40, 0xc8206e8380, 0x16, 0x1082b00)\r\n\t/home/dfc/go/src/encoding/json/encode.go:709 +0xd0 fp=0xc820aedbc0 sp=0xc820aedb88\r\nencoding/json.(*ptrEncoder).(encoding/json.encode)-fm(0xc82020e0b0, 0x1082b40, 0xc8206e8380, 0x16, 0xc8206e8300)\r\n\t/home/dfc/go/src/encoding/json/encode.go:714 +0x51 fp=0xc820aedbf8 sp=0xc820aedbc0\r\nencoding/json.(*encodeState).reflectValue(0xc82020e0b0, 0x1082b40, 0xc8206e8380, 0x16)\r\n\t/home/dfc/go/src/encoding/json/encode.go:301 +0x6e fp=0xc820aedc28 sp=0xc820aedbf8\r\nencoding/json.(*encodeState).marshal(0xc82020e0b0, 0x1082b40, 0xc8206e8380, 0x0, 0x0)\r\n\t/home/dfc/go/src/encoding/json/encode.go:274 +0x93 fp=0xc820aedc58 sp=0xc820aedc28\r\nencoding/json.Marshal(0x1082b40, 0xc8206e8380, 0x11efda0, 0x2, 0x134e5d8, 0xc8206e8380, 0x80)\r\n\t/home/dfc/go/src/encoding/json/encode.go:139 +0x5f fp=0xc820aedc90 sp=0xc820aedc58\r\ngolang.org/x/net/websocket.jsonMarshal(0x1082b40, 0xc8206e8380, 0xc82013ae80, 0xc82002ec00, 0x7f6f11a9e000, 0x0, 0x7, 0x7)\r\n\t/home/dfc/src/golang.org/x/net/websocket/websocket.go:385 +0x2b fp=0xc820aedcd0 sp=0xc820aedc90\r\ngolang.org/x/net/websocket.Codec.Send(0x15a32d0, 0x15a32d8, 0xc8206ac240, 0x1082b40, 0xc8206e8380, 0x0, 0x0)\r\n\t/home/dfc/src/golang.org/x/net/websocket/websocket.go:288 +0x58 fp=0xc820aedd50 sp=0xc820aedcd0\r\ngithub.com/juju/juju/rpc/jsoncodec.wsJSONConn.Send(0xc8206ac240, 0x1082b40, 0xc8206e8380, 0x1052ee0, 0xc82038ca40)\r\n\t/home/dfc/src/github.com/juju/juju/rpc/jsoncodec/conn.go:21 +0x4d fp=0xc820aedd90 sp=0xc820aedd50\r\ngithub.com/juju/juju/rpc/jsoncodec.(*Codec).WriteMessage(0xc8202a8b00, 0xc8206ae180, 0x1194940, 0xc82017b920, 0x0, 0x0)\r\n\t/home/dfc/src/github.com/juju/juju/rpc/jsoncodec/codec.go:182 +0x19a fp=0xc820aede20 sp=0xc820aedd90\r\ngithub.com/juju/juju/rpc.(*Conn).runRequest(0xc8204fe6e0, 0x7f6f11a32ea0, 0xc820303180, 0x15a24a0, 0x3, 0xc8205f9022, 0x6, 0x1, 0x0, 0x0, ...)\r\n\t/home/dfc/src/github.com/juju/juju/rpc/server.go:572 +0x387 fp=0xc820aeded0 sp=0xc820aede20\r\nruntime.goexit()\r\n\t/home/dfc/go/src/runtime/asm_amd64.s:2006 +0x1 fp=0xc820aeded8 sp=0xc820aeded0\r\ncreated by github.com/juju/juju/rpc.(*Conn).handleRequest\r\n\t/home/dfc/src/github.com/juju/juju/rpc/server.go:489 +0x66d\r\n```\r\n\r\n/cc @khr @aclements "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/200667547","html_url":"https://github.com/golang/go/issues/14904#issuecomment-200667547","issue_url":"https://api.github.com/repos/golang/go/issues/14904","id":200667547,"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},"created_at":"2016-03-24T05:07:41Z","updated_at":"2016-03-24T05:07:41Z","body":"Current suspect: github.com/juju/juju/apiserver/client/status.go:(*statusContext).processService\r\nAt the very end, it does \"return processStatus\".  But processStatus is also a named return value.  I think this is confusing SSA, as at the end of the function it generates:\r\n```\r\nv472\t23075 (status.go:658)\tVARDEF\t\"\".processedStatus+16(FP)\r\nv265\t23076 (status.go:658)\tMOVQ\t\"\".processedStatus+16(FP), AX\r\nv267\t23077 (status.go:658)\tMOVQ\tAX, \"\".processedStatus+16(FP)\r\nv161\t23078 (status.go:658)\tLEAQ\t\"\".processedStatus+24(FP), DI\r\nv157\t23079 (status.go:658)\tMOVQ\tDI, SI\r\nv473\t23080 (status.go:658)\tDUFFCOPY\t$658\r\nb57\t23081 (status.go:658)\tRET\r\n```\r\nIt's basically doing processedStatus = processedStatus using DUFFCOPY, but the VARDEF at the start tells the live variable analysis that processedStatus is dead before this code.  Thus the GC won't scan any pointers in this structure, and it contains (among other things) maps.\r\n\r\nSo named return values being copied to themselves in a return statement may be buggy.  I'll try to make a small repro and a fix tomorrow.\r\n\r\nChanging \"return processedStatus\" to \"return\" fixed everything.  Someone might want to do that to the juju sources, as it is better style and matches the other returns in the function.  But I'll definitely fix this on the SSA end, we should generate correct code regardless."}}