bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.96k stars 556 forks source link

webmock causes debugger to crash #102

Closed hackervera closed 13 years ago

hackervera commented 13 years ago

My test passes when I run it, but debugger crashes. here it output of debugger

/Users/tyler/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/bin/rdebug-ide --debug --port 50271 -- /Users/tyler/.rvm/gems/ruby-1.9.2-p180/bin/rspec /Users/tyler/plexus-em/spec/plexus/twitterusers_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --example set_feed_url
Testing started at 6:38 AM ...
Fast Debugger (ruby-debug-ide 0.4.17.beta5, ruby-debug-base 0.11.28) listens on 127.0.0.1:50271
Starting control thread
Processing in control: b /Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:40
<breakpointAdded no="1" location="/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:40"/>
Processing in control: b /Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:32
<breakpointAdded no="2" location="/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:32"/>
Processing in control: start
Starting: running program script
Empty test suite.
"in method"
2
Empty test suite.
"adding tylergillies with http://www.mashable.com"
<breakpoint file="/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb" line="32" threadId="1"/>
Stopping Thread #<Thread:0x0000010086fe88>
Threads equal: true
Processing in control: th l
<threads>
<thread id="1" status="sleep" />
</threads>
Processing in control: th l
<threads>
<thread id="1" status="sleep" />
</threads>
"adding dude with http://www.google.com"
Processing in context: w
<frames>
<frame no='1' file='/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb' line='32' current='true' />
<frame no='2' file='/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb' line='31' />
<frame no='3' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/em-synchrony-0.2.0/lib/em-synchrony/em-multi.rb' line='0' />
<frame no='4' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb' line='0' />
<frame no='5' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb' line='0' />
<frame no='6' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb' line='0' />
<frame no='7' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/http_lib_adapters/em_http_request.rb' line='0' />
<frame no='8' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb' line='0' />
<frame no='9' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb' line='0' />
<frame no='10' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb' line='0' />
<frame no='11' file='/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb' line='0' />
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:92: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.5.0]

-- control frame ----------
c:0040 p:---- s:0142 b:0142 l:000141 d:000141 CFUNC  :frame_file
c:0039 p:0014 s:0138 b:0138 l:000137 d:000137 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:92
c:0038 p:0026 s:0131 b:0131 l:000125 d:000130 BLOCK  (eval):5
c:0037 p:0019 s:0129 b:0129 l:000128 d:000128 METHOD /Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201
c:0036 p:0012 s:0126 b:0126 l:000125 d:000125 METHOD (eval):3
c:0035 p:0018 s:0121 b:0121 l:000578 d:000120 BLOCK  /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:81
c:0034 p:---- s:0118 b:0118 l:000117 d:000117 FINISH
c:0033 p:---- s:0116 b:0116 l:000115 d:000115 CFUNC  :each
c:0032 p:0023 s:0113 b:0113 l:000578 d:000112 BLOCK  /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:80
c:0031 p:0028 s:0111 b:0111 l:000110 d:000110 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:299
c:0030 p:0026 s:0107 b:0107 l:000101 d:000106 BLOCK  (eval):5
c:0029 p:0019 s:0105 b:0105 l:000104 d:000104 METHOD /Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201
c:0028 p:0012 s:0102 b:0102 l:000101 d:000101 METHOD (eval):3
c:0027 p:0013 s:0097 b:0097 l:000578 d:000578 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:79
c:0026 p:0026 s:0092 b:0092 l:000086 d:000091 BLOCK  (eval):5
c:0025 p:0019 s:0090 b:0090 l:000089 d:000089 METHOD /Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201
c:0024 p:0012 s:0087 b:0087 l:000086 d:000086 METHOD (eval):3
c:0023 p:0034 s:0082 b:0082 l:000081 d:000081 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/command.rb:85
c:0022 p:---- s:0076 b:0076 l:000075 d:000075 FINISH
c:0021 p:0029 s:0074 b:0074 l:000073 d:000073 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/commands/frame.rb:41
c:0020 p:0103 s:0071 b:0071 l:000052 d:000070 BLOCK  /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:50
c:0019 p:---- s:0066 b:0066 l:000065 d:000065 FINISH
c:0018 p:---- s:0064 b:0064 l:000063 d:000063 CFUNC  :each
c:0017 p:0020 s:0061 b:0061 l:000052 d:000060 BLOCK  /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:43
c:0016 p:---- s:0059 b:0059 l:000058 d:000058 FINISH
c:0015 p:---- s:0057 b:0057 l:000056 d:000056 CFUNC  :catch
c:0014 p:0261 s:0053 b:0053 l:000052 d:000052 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:42
c:0013 p:0222 s:0044 b:0044 l:000043 d:000043 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/event_processor.rb:61
c:0012 p:0059 s:0037 b:0037 l:000036 d:000036 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/event_processor.rb:37
c:0011 p:0022 s:0031 b:0031 l:000030 d:000030 METHOD /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug-ide.rb:60
c:0010 p:---- s:0026 b:0026 l:000025 d:000025 FINISH
c:0009 p:0002 s:0024 b:0024 l:001818 d:001e00 BLOCK  /Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:32
c:0008 p:---- s:0021 b:0021 l:000020 d:000020 FINISH
c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :each
c:0006 p:0136 s:0016 b:0016 l:001818 d:000a88 BLOCK  /Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:31
c:0005 p:---- s:0010 b:0010 l:000009 d:000009 FINISH
c:0004 p:---- s:0008 b:0008 l:000007 d:000007 CFUNC  :call
c:0003 p:0011 s:0005 b:0005 l:000798 d:000004 BLOCK  /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/em-synchrony-0.2.0/lib/em-synchrony.rb:24
c:0002 p:---- s:0003 b:0003 l:000002 d:000002 FINISH
c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------
---------------------------
-- Ruby level backtrace information ----------------------------------------
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/em-synchrony-0.2.0/lib/em-synchrony.rb:24:in `block (2 levels) in synchrony'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/em-synchrony-0.2.0/lib/em-synchrony.rb:24:in `call'
/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:31:in `block in set_feed_url'
/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:31:in `each'
/Users/tyler/plexus-em/lib/plexus/twitterusers/setfeed.rb:32:in `block (2 levels) in set_feed_url'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug-ide.rb:60:in `at_line'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/event_processor.rb:37:in `at_line'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/event_processor.rb:61:in `line_event'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:42:in `process_commands'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:42:in `catch'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:43:in `block in process_commands'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:43:in `each'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/ide_processor.rb:50:in `block (2 levels) in process_commands'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/commands/frame.rb:41:in `execute'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/command.rb:85:in `method_missing'
(eval):3:in `print_frames'
/Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
(eval):5:in `block in print_frames'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:79:in `print_frames'
(eval):3:in `print_element'
/Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
(eval):5:in `block in print_element'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:299:in `print_element'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:80:in `block in print_frames'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:80:in `each'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:81:in `block (2 levels) in print_frames'
(eval):3:in `print_frame'
/Users/tyler/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
(eval):5:in `block in print_frame'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:92:in `print_frame'
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:92:in `frame_file'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Process finished with exit code 134

here is my test

  describe "#set_feed_url" do
    it "should take the url of the user and return a Feedzirra object" do
      people = [{:id => 'tylergillies', :meta =>{'url' => 'http://www.mashable.com'}}, {:id => 'dude', :meta => {'url' => 'http://www.google.com'}}]
      stub_request(:get, /.*/).to_return(:body => %Q^<link rel="alternate" type="application/rss+xml" title="Mashable" href="http://feeds.mashable.com/mashable" />^)
      stub_request(:get, /feeds/).to_return(:body => test_rss)
      @twitterusers.people = people
      @twitterusers.set_feed_url
      @twitterusers.people.each do |person|
        if person[:feed]
          person[:feed].class.to_s.should =~ /Feedzirra::/
        end
      end
    end
  end

here is the method

  def set_feed_url
    p "in method"
    EM.synchrony{

      @people.reject!{|person| person[:meta]['url'].nil?}
      p @people.length
      multi = EventMachine::Synchrony::Multi.new
      @people.each do |person|
        foo =   EventMachine::HttpRequest.new(person[:meta]['url']).aget :redirects => 1
        multi.add :"#{person[:id]}",   foo
        p "adding #{person[:id]} with #{person[:meta]['url']}"
      end
      res = multi.perform

      res.responses[:callback].each do |id,client|

        person = @people.select{|person| :"#{person[:id]}" == id}.first
        feed_url = TruffleHog.parse_feed_urls(client.response).first
        person[:feed_url] = feed_url
      end

      multi2 =  EventMachine::Synchrony::Multi.new
      @people.select{|person| person[:feed_url]}.each do |person|
        multi2.add  :"#{person[:id]}", EventMachine::HttpRequest.new(person[:feed_url]).aget(:redirects => 1)
      end
      res2 =  multi2.perform
      res2.responses[:callback].each do |id,client|
        person = @people.select{|person| :"#{person[:id]}" == id}.first
        feed = Feedzirra::Feed.parse(client.response)
        person[:feed] = feed
      end
      EM.stop
    }

  end
jcf commented 13 years ago

It looks like the segfault is coming from xml_printer.rb in your ruby-debug-ide gem and this leads me to believe it's not an issue with WebMock.

/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug/xml_printer.rb:92: [BUG] Segmentation fault

I'm closing this issue pending a more specific description of a fault within WebMock.

myronmarston commented 13 years ago

You might try using the console debugger (ruby-debug rather than ruby-debug-ide). I've used that debugger many times with test suites that use webmock.

hackervera commented 13 years ago

You might try using the console debugger (ruby-debug rather than ruby-debug-ide). I've used that debugger many times with test suites that use webmock.

awesome, thanks