{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/20775","labels_url":"https://api.github.com/repos/rails/rails/issues/20775/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/20775/comments","events_url":"https://api.github.com/repos/rails/rails/issues/20775/events","html_url":"https://github.com/rails/rails/issues/20775","id":92915219,"number":20775,"title":"ActiveSupport 4.2 - `JSON.dump` broken for Structs","user":{"login":"arnvald","id":135708,"avatar_url":"https://avatars.githubusercontent.com/u/135708?v=3","gravatar_id":"","url":"https://api.github.com/users/arnvald","html_url":"https://github.com/arnvald","followers_url":"https://api.github.com/users/arnvald/followers","following_url":"https://api.github.com/users/arnvald/following{/other_user}","gists_url":"https://api.github.com/users/arnvald/gists{/gist_id}","starred_url":"https://api.github.com/users/arnvald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnvald/subscriptions","organizations_url":"https://api.github.com/users/arnvald/orgs","repos_url":"https://api.github.com/users/arnvald/repos","events_url":"https://api.github.com/users/arnvald/events{/privacy}","received_events_url":"https://api.github.com/users/arnvald/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/activesupport","name":"activesupport","color":"FC9300"},{"url":"https://api.github.com/repos/rails/rails/labels/regression","name":"regression","color":"e10c02"},{"url":"https://api.github.com/repos/rails/rails/labels/With%20reproduction%20steps","name":"With reproduction steps","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/42","html_url":"https://github.com/rails/rails/milestones/4.2.4","labels_url":"https://api.github.com/repos/rails/rails/milestones/42/labels","id":1179399,"number":42,"title":"4.2.4","description":"","creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":5,"state":"open","created_at":"2015-06-24T15:02:28Z","updated_at":"2015-07-05T10:44:06Z","due_on":null,"closed_at":null},"comments":11,"created_at":"2015-07-03T17:45:30Z","updated_at":"2015-07-06T18:19:05Z","closed_at":null,"body":"Hi everyone,\r\n\r\nToday I've noticed that ActiveSupport 4.2 breaks `JSON.dump` (\"stack level too deep\") for the arrays/hashes containing structs.\r\n\r\nExample:\r\n```ruby\r\nirb(main):001:0> require 'json'\r\n=> true\r\nirb(main):002:0> obj = Struct.new(:key).new\r\n=> #<struct key=nil>\r\nirb(main):003:0> JSON.dump([obj])\r\n=> \"[\\\"#<struct key=nil>\\\"]\"\r\nirb(main):004:0> require 'active_support/json'\r\n=> true\r\nirb(main):005:0> JSON.dump([obj])\r\nSystemStackError: stack level too deep\r\n```\r\n\r\nStack trace shows that this line `activesupport-4.2.0/lib/active_support/core_ext/object/json.rb:34:in `to_json_with_active_support_encoder'` is called over and over.\r\n\r\nI tried to figure out why is it failing, but I couldn't find the root of the problem.\r\nIf you have any hint on how I can provide more useful information, let me know.\r\n\r\nThis issue appears in ActiveSupport 4.2.x (I've checked 4.2.0 and 4.2.3), but it does not appear in 4.1.x"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/118944173","html_url":"https://github.com/rails/rails/issues/20775#issuecomment-118944173","issue_url":"https://api.github.com/repos/rails/rails/issues/20775","id":118944173,"user":{"login":"chancancode","id":55829,"avatar_url":"https://avatars.githubusercontent.com/u/55829?v=3","gravatar_id":"","url":"https://api.github.com/users/chancancode","html_url":"https://github.com/chancancode","followers_url":"https://api.github.com/users/chancancode/followers","following_url":"https://api.github.com/users/chancancode/following{/other_user}","gists_url":"https://api.github.com/users/chancancode/gists{/gist_id}","starred_url":"https://api.github.com/users/chancancode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chancancode/subscriptions","organizations_url":"https://api.github.com/users/chancancode/orgs","repos_url":"https://api.github.com/users/chancancode/repos","events_url":"https://api.github.com/users/chancancode/events{/privacy}","received_events_url":"https://api.github.com/users/chancancode/received_events","type":"User","site_admin":false},"created_at":"2015-07-06T18:19:05Z","updated_at":"2015-07-06T18:19:05Z","body":"I also still don't know why the `alias_method_chain` on `Enumerable` isn't failing with an error, if someone figured that out please educate me :grin:"}}