{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/2314","labels_url":"https://api.github.com/repos/jruby/jruby/issues/2314/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/2314/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/2314/events","html_url":"https://github.com/jruby/jruby/issues/2314","id":51865460,"number":2314,"title":"Infinite loop when using mutually-referential constants","user":{"login":"jeremyevans","id":3846,"avatar_url":"https://avatars.githubusercontent.com/u/3846?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyevans","html_url":"https://github.com/jeremyevans","followers_url":"https://api.github.com/users/jeremyevans/followers","following_url":"https://api.github.com/users/jeremyevans/following{/other_user}","gists_url":"https://api.github.com/users/jeremyevans/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyevans/subscriptions","organizations_url":"https://api.github.com/users/jeremyevans/orgs","repos_url":"https://api.github.com/users/jeremyevans/repos","events_url":"https://api.github.com/users/jeremyevans/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyevans/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jruby/jruby/labels/core","name":"core","color":"02e10c"},{"url":"https://api.github.com/repos/jruby/jruby/labels/JRuby%201.7.x","name":"JRuby 1.7.x","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/jruby/jruby/milestones/31","html_url":"https://github.com/jruby/jruby/milestones/JRuby%201.7.20","labels_url":"https://api.github.com/repos/jruby/jruby/milestones/31/labels","id":912734,"number":31,"title":"JRuby 1.7.20","description":"","creator":{"login":"enebo","id":19819,"avatar_url":"https://avatars.githubusercontent.com/u/19819?v=3","gravatar_id":"","url":"https://api.github.com/users/enebo","html_url":"https://github.com/enebo","followers_url":"https://api.github.com/users/enebo/followers","following_url":"https://api.github.com/users/enebo/following{/other_user}","gists_url":"https://api.github.com/users/enebo/gists{/gist_id}","starred_url":"https://api.github.com/users/enebo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enebo/subscriptions","organizations_url":"https://api.github.com/users/enebo/orgs","repos_url":"https://api.github.com/users/enebo/repos","events_url":"https://api.github.com/users/enebo/events{/privacy}","received_events_url":"https://api.github.com/users/enebo/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":48,"state":"open","created_at":"2014-12-22T21:27:27Z","updated_at":"2015-04-30T15:59:51Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2014-12-12T23:32:40Z","updated_at":"2015-04-30T18:08:03Z","closed_at":null,"body":"The following code appears to cause an infinite loop in JRuby 1.7.17 (OpenBSD) and 1.7.6 (Windows):\r\n\r\n```ruby\r\ndef a\r\n  c = Class.new\r\n  c2 = Class.new\r\n  c.const_set(:A, c2)\r\n  c2.const_set(:A, c)\r\nend\r\n```\r\n\r\nCalling that `a` method causes the CPU to go to 100%, and requires a `kill -9` to kill the process."},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/97900760","html_url":"https://github.com/jruby/jruby/issues/2314#issuecomment-97900760","issue_url":"https://api.github.com/repos/jruby/jruby/issues/2314","id":97900760,"user":{"login":"headius","id":10135,"avatar_url":"https://avatars.githubusercontent.com/u/10135?v=3","gravatar_id":"","url":"https://api.github.com/users/headius","html_url":"https://github.com/headius","followers_url":"https://api.github.com/users/headius/followers","following_url":"https://api.github.com/users/headius/following{/other_user}","gists_url":"https://api.github.com/users/headius/gists{/gist_id}","starred_url":"https://api.github.com/users/headius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headius/subscriptions","organizations_url":"https://api.github.com/users/headius/orgs","repos_url":"https://api.github.com/users/headius/repos","events_url":"https://api.github.com/users/headius/events{/privacy}","received_events_url":"https://api.github.com/users/headius/received_events","type":"User","site_admin":false},"created_at":"2015-04-30T18:08:03Z","updated_at":"2015-04-30T18:08:03Z","body":"With @evanphx's help, I've discovered that .name on detached namespaces is orders of magnitude slower than namespaces reachable from Object, due to the fact that they have to keep re-searching for the module every time.\r\n\r\n```ruby\r\nrequire 'benchmark'\r\n\r\nmodule B\r\n  module X\r\n  end\r\nend\r\n\r\ndef a\r\n  c = Class.new\r\n  c2 = Class.new\r\n  c.class_eval 'A = c2'\r\n  c2.class_eval 'A = c'\r\n  \r\n  c\r\nend\r\n\r\nc = a\r\nx = B::X\r\n\r\nloop do\r\n  puts 'named'\r\n  puts Benchmark.measure { 1_000_000.times { x.name } }\r\n  puts 'anon'\r\n  puts Benchmark.measure { 1_000_000.times { c.name } }\r\nend\r\n```\r\n\r\nAnd results:\r\n\r\n```\r\nnamed\r\n  0.190000   0.000000   0.190000 (  0.188228)\r\nanon\r\n 12.810000   0.020000  12.830000 ( 12.846686)\r\n```\r\n\r\nWe are going to fix this in some way, but if you have *any* namespaces unreachable from Object, you really shouldn't be calling `#name` on them."}}