{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10769","labels_url":"https://api.github.com/repos/golang/go/issues/10769/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10769/comments","events_url":"https://api.github.com/repos/golang/go/issues/10769/events","html_url":"https://github.com/golang/go/issues/10769","id":74980875,"number":10769,"title":"encoding/json: stack overflow","user":{"login":"bep","id":394382,"avatar_url":"https://avatars.githubusercontent.com/u/394382?v=3","gravatar_id":"","url":"https://api.github.com/users/bep","html_url":"https://github.com/bep","followers_url":"https://api.github.com/users/bep/followers","following_url":"https://api.github.com/users/bep/following{/other_user}","gists_url":"https://api.github.com/users/bep/gists{/gist_id}","starred_url":"https://api.github.com/users/bep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bep/subscriptions","organizations_url":"https://api.github.com/users/bep/orgs","repos_url":"https://api.github.com/users/bep/repos","events_url":"https://api.github.com/users/bep/events{/privacy}","received_events_url":"https://api.github.com/users/bep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-10T19:13:32Z","updated_at":"2015-05-10T19:34:13Z","closed_at":null,"body":"The following program panics.\r\n\r\nOS: Linux\r\nGo version: tip and 1.4.2\r\n\r\nI searched, but didn't find this in here.\r\n\r\n/cc @dvyukov go-fuzz\r\n\r\n\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"html/template\"\r\n\t\"io/ioutil\"\r\n)\r\n\r\nfunc main() {\r\n\tt, err := template.New(\"foo\").Parse(data)\r\n\tif err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\ta := &A{}\r\n\ta.B1 = &B{a}\r\n\tping := &Ping{a}\r\n\r\n\tt.Execute(ioutil.Discard, ping)\r\n}\r\n\r\nvar data = \"<script>{{ .Pong }}</script>\"\r\n\r\ntype Ping struct {\r\n\tPong *A\r\n}\r\n\r\ntype A struct {\r\n\tB1 *B\r\n}\r\n\r\ntype B struct {\r\n\tA1 *A\r\n}\r\n```\r\n\r\n```\r\nruntime: goroutine stack exceeds 1000000000-byte limit\r\nfatal error: stack overflow\r\n\r\nruntime stack:\r\nruntime.throw(0x5e7490, 0xe)\r\n\t/home/bep/dev/golang/go/src/runtime/panic.go:543 +0x96\r\nruntime.newstack()\r\n\t/home/bep/dev/golang/go/src/runtime/stack1.go:744 +0xb3f\r\nruntime.morestack()\r\n\t/home/bep/dev/golang/go/src/runtime/asm_amd64.s:330 +0x82\r\n\r\ngoroutine 1 [stack growth]:\r\nencoding/json.(*structEncoder).encode(0xc208012e40, 0xc208095810, 0x585560, 0xc208028038, 0xd9, 0x0)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:569 fp=0xc2280fa280 sp=0xc2280fa278\r\nencoding/json.(*structEncoder).(encoding/json.encode)-fm(0xc208095810, 0x585560, 0xc208028038, 0xd9, 0x5bf900)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:598 +0x58 fp=0xc2280fa2b8 sp=0xc2280fa280\r\nencoding/json.typeEncoder.func1(0xc208095810, 0x585560, 0xc208028038, 0xd9, 0xc208028000)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:336 +0x6d fp=0xc2280fa2f0 sp=0xc2280fa2b8\r\nencoding/json.(*ptrEncoder).encode(0xc208028088, 0xc208095810, 0x531e60, 0xc208028040, 0xd6, 0x4c5200)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:706 +0xed fp=0xc2280fa340 sp=0xc2280fa2f0\r\nencoding/json.(*ptrEncoder).(encoding/json.encode)-fm(0xc208095810, 0x531e60, 0xc208028040, 0xd6, 0x0)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:711 +0x58 fp=0xc2280fa378 sp=0xc2280fa340\r\nencoding/json.(*structEncoder).encode(0xc208012f30, 0xc208095810, 0x585620, 0xc208028040, 0xd9, 0x4aad00)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:584 +0x2c3 fp=0xc2280fa520 sp=0xc2280fa378\r\nencoding/json.(*structEncoder).(encoding/json.encode)-fm(0xc208095810, 0x585620, 0xc208028040, 0xd9, 0xc208028000)\r\n\t/home/bep/dev/golang/go/src/encoding/json/encode.go:598 +0x58 fp=0xc2280fa558 sp=0xc2280fa520\r\nencoding/json.(*ptrEncoder).encode(0xc208028090, 0xc208095810, 0x531ec0, 0xc208028038, 0xd6, 0x4c5200)\r\n\t/home/bep/dev/g\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/100685679","html_url":"https://github.com/golang/go/issues/10769#issuecomment-100685679","issue_url":"https://api.github.com/repos/golang/go/issues/10769","id":100685679,"user":{"login":"bep","id":394382,"avatar_url":"https://avatars.githubusercontent.com/u/394382?v=3","gravatar_id":"","url":"https://api.github.com/users/bep","html_url":"https://github.com/bep","followers_url":"https://api.github.com/users/bep/followers","following_url":"https://api.github.com/users/bep/following{/other_user}","gists_url":"https://api.github.com/users/bep/gists{/gist_id}","starred_url":"https://api.github.com/users/bep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bep/subscriptions","organizations_url":"https://api.github.com/users/bep/orgs","repos_url":"https://api.github.com/users/bep/repos","events_url":"https://api.github.com/users/bep/events{/privacy}","received_events_url":"https://api.github.com/users/bep/received_events","type":"User","site_admin":false},"created_at":"2015-05-10T19:34:13Z","updated_at":"2015-05-10T19:34:13Z","body":"The json package says:\r\n\r\n```\r\nJSON cannot represent cyclic data structures and Marshal does not\r\nhandle them.  Passing cyclic structures to Marshal will result in\r\nan infinite recursion.\r\n```\r\nThe template package says:\r\n```\r\n See package json to understand how non-string content is marshalled for embedding in JavaScript contexts. \r\n```\r\n\r\nSo, I guess you are kind of correct when you say that this is a documented limitation ... But ...\r\n"}}