{"action":"created","issue":{"url":"https://api.github.com/repos/eventmachine/eventmachine/issues/765","repository_url":"https://api.github.com/repos/eventmachine/eventmachine","labels_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/765/labels{/name}","comments_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/765/comments","events_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/765/events","html_url":"https://github.com/eventmachine/eventmachine/issues/765","id":204545326,"number":765,"title":"Segfault from EM.run after EM::Connection#unbind raises exception","user":{"login":"SpComb","id":3950373,"avatar_url":"https://avatars.githubusercontent.com/u/3950373?v=3","gravatar_id":"","url":"https://api.github.com/users/SpComb","html_url":"https://github.com/SpComb","followers_url":"https://api.github.com/users/SpComb/followers","following_url":"https://api.github.com/users/SpComb/following{/other_user}","gists_url":"https://api.github.com/users/SpComb/gists{/gist_id}","starred_url":"https://api.github.com/users/SpComb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpComb/subscriptions","organizations_url":"https://api.github.com/users/SpComb/orgs","repos_url":"https://api.github.com/users/SpComb/repos","events_url":"https://api.github.com/users/SpComb/events{/privacy}","received_events_url":"https://api.github.com/users/SpComb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-02-01T10:23:24Z","updated_at":"2017-02-23T05:56:49Z","closed_at":null,"body":"I experienced a segfault similar to  #758 and  #761 when trying to write rspecs for a `faye/websocket` client, using an `EM.run { ... }` pattern similar to [`tests/test_unbind_reason.rb`](https://github.com/eventmachine/eventmachine/blob/master/tests/test_unbind_reason.rb).\r\n\r\nThe following minimal repro crashes with a segfault when run with `CRASH_EM=1`:\r\n\r\n```ruby\r\n#!/usr/bin/env ruby\r\n\r\nrequire 'eventmachine'\r\n\r\nclass Subject < EM::Connection\r\n  def self.connect(host, port)\r\n    STDERR.puts \"EM.connect...\"\r\n\r\n    EM.connect '127.0.0.1', 1337, self\r\n  end\r\n\r\n  def unbind(reason = nil)\r\n    STDERR.puts \"EM::Connection.unbind: #{reason}\"\r\n\r\n    fail 'crash EventMachine' if ENV['CRASH_EM']\r\n\r\n    EM.stop\r\n  rescue => exc\r\n    STDERR.puts \"raise #{exc}:\\n#{exc.backtrace.join \"\\n\"}\\n\\n\"\r\n    raise\r\n  end\r\nend\r\n\r\nSTDERR.puts \"EM.run...\"\r\nEM.run {\r\n  STDERR.puts \"EM.run &block start\"\r\n  conn = Subject.connect('127.0.0.1', 1337)\r\n  STDERR.puts \"EM.run &block end\"\r\n}\r\nSTDERR.puts \"EM.run returned\"\r\n```\r\n\r\n#### `ruby bin/em-test`\r\n```\r\nEM.run...\r\nEM.run &block start\r\nEM.connect...\r\nEM.run &block end\r\nEM::Connection.unbind: Errno::ECONNREFUSED\r\nEM.run returned\r\n```\r\n\r\n#### `CRASH_EM=1 ruby bin/em-test`\r\n```\r\nEM.run...\r\nEM.run &block start\r\nEM.connect...\r\nEM.run &block end\r\nEM::Connection.unbind: Errno::ECONNREFUSED\r\nraise crash EventMachine:\r\nbin/em-test:15:in `unbind'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:1481:in `event_callback'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:194:in `run_machine'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:194:in `run'\r\nbin/em-test:25:in `<main>'\r\n\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:202: [BUG] Segmentation fault at 0x00000000000000\r\nruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]\r\n\r\n-- Control frame information -----------------------------------------------\r\nc:0005 p:---- s:0017 e:000016 CFUNC  :release_machine\r\nc:0004 p:0036 s:0014 e:000013 RESCUE /home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:202\r\nc:0003 p:0385 s:0011 e:000010 METHOD /home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:205\r\nc:0002 p:0055 s:0004 E:0002a0 EVAL   bin/em-test:25 [FINISH]\r\nc:0001 p:0000 s:0002 E:0005a0 (none) [FINISH]\r\n\r\n-- Ruby level backtrace information ----------------------------------------\r\nbin/em-test:25:in `<main>'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:205:in `run'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:202:in `ensure in run'\r\n/home/kontena/.gem/ruby/2.3.0/gems/eventmachine-1.2.2/lib/eventmachine.rb:202:in `release_machine'\r\n```"},"comment":{"url":"https://api.github.com/repos/eventmachine/eventmachine/issues/comments/281902304","html_url":"https://github.com/eventmachine/eventmachine/issues/765#issuecomment-281902304","issue_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/765","id":281902304,"user":{"login":"sodabrew","id":39406,"avatar_url":"https://avatars.githubusercontent.com/u/39406?v=3","gravatar_id":"","url":"https://api.github.com/users/sodabrew","html_url":"https://github.com/sodabrew","followers_url":"https://api.github.com/users/sodabrew/followers","following_url":"https://api.github.com/users/sodabrew/following{/other_user}","gists_url":"https://api.github.com/users/sodabrew/gists{/gist_id}","starred_url":"https://api.github.com/users/sodabrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodabrew/subscriptions","organizations_url":"https://api.github.com/users/sodabrew/orgs","repos_url":"https://api.github.com/users/sodabrew/repos","events_url":"https://api.github.com/users/sodabrew/events{/privacy}","received_events_url":"https://api.github.com/users/sodabrew/received_events","type":"User","site_admin":false},"created_at":"2017-02-23T05:56:49Z","updated_at":"2017-02-23T05:56:49Z","body":"Please try the new EventMachine 1.2.3 release, it should resolve this crash!"}}
{"actor":{"display_login":"sodabrew"}}