mperham / rack-fiber_pool

Rack middleware to execute each request in a Fiber
MIT License
244 stars 24 forks source link

Hard crash when using fiber_pool with thin #15

Closed ansman closed 12 years ago

ansman commented 12 years ago

When I try to run the example app in the project I get this output:

$ rackup -s thin app.rb
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/fiber_pool.rb:75: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]

-- control frame ----------
c:0040 p:---- s:0189 b:0189 l:000188 d:000188 CFUNC  :resume
c:0039 p:0067 s:0185 b:0185 l:000184 d:000184 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/fiber_pool.rb:75
c:0038 p:0026 s:0180 b:0180 l:002048 d:002048 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/rack/fiber_pool.rb:28
c:0037 p:0015 s:0175 b:0175 l:000174 d:000174 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22
c:0036 p:0055 s:0168 b:0168 l:000167 d:000167 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16
c:0035 p:0019 s:0163 b:0163 l:000162 d:000162 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17
c:0034 p:0075 s:0155 b:0155 l:000154 d:000154 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47
c:0033 p:0015 s:0150 b:0150 l:000149 d:000149 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22
c:0032 p:0029 s:0143 b:0143 l:000142 d:000142 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/nulllogger.rb:9
c:0031 p:0015 s:0139 b:0139 l:000138 d:000138 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/head.rb:9
c:0030 p:0015 s:0132 b:0132 l:000131 d:000131 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21
c:0029 p:0018 s:0124 b:0124 l:000700 d:000123 BLOCK  /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334
c:0028 p:0032 s:0122 b:0122 l:000121 d:000121 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416
c:0027 p:0011 s:0118 b:0118 l:000700 d:000700 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334
c:0026 p:0103 s:0114 b:0114 l:0001e0 d:0001e0 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/lint.rb:48
c:0025 p:0022 s:0108 b:0108 l:000107 d:000107 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/lint.rb:36
c:0024 p:0015 s:0104 b:0104 l:000103 d:000103 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/showexceptions.rb:24
c:0023 p:0032 s:0096 b:0096 l:000095 d:000095 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/commonlogger.rb:20
c:0022 p:0015 s:0088 b:0088 l:000087 d:000087 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/chunked.rb:43
c:0021 p:0015 s:0081 b:0081 l:000080 d:000080 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/content_length.rb:14
c:0020 p:0020 s:0072 b:0072 l:000063 d:000071 BLOCK  /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:84
c:0019 p:---- s:0070 b:0070 l:000069 d:000069 FINISH
c:0018 p:---- s:0068 b:0068 l:000067 d:000067 CFUNC  :catch
c:0017 p:0135 s:0064 b:0064 l:000063 d:000063 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:82
c:0016 p:0088 s:0059 b:0058 l:000057 d:000057 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:57
c:0015 p:0036 s:0055 b:0055 l:000054 d:000054 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:42
c:0014 p:---- s:0050 b:0050 l:000049 d:000049 FINISH
c:0013 p:---- s:0048 b:0048 l:000047 d:000047 CFUNC  :run_machine
c:0012 p:0248 s:0045 b:0045 l:000044 d:000044 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256
c:0011 p:0066 s:0038 b:0038 l:0013b0 d:0013b0 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/backends/base.rb:61
c:0010 p:0143 s:0034 b:0034 l:000033 d:000033 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/server.rb:159
c:0009 p:0081 s:0031 b:0031 l:000030 d:000030 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/handler/thin.rb:13
c:0008 p:0271 s:0025 b:0025 l:0020a0 d:0020a0 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/server.rb:265
c:0007 p:0022 s:0019 b:0019 l:000018 d:000018 METHOD /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/server.rb:137
c:0006 p:0029 s:0015 b:0015 l:000014 d:000014 TOP    /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/bin/rackup:4
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :load
c:0003 p:0127 s:0007 b:0007 l:0015a8 d:0011b0 EVAL   /Users/nicklas/.rvm/gems/ruby-1.9.2-p290/bin/rackup:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0015a8 d:0015a8 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/bin/rackup:19:in `<main>'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/bin/rackup:19:in `load'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/bin/rackup:4:in `<top (required)>'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/server.rb:137:in `start'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/server.rb:265:in `start'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/handler/thin.rb:13:in `run'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/content_length.rb:14:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/chunked.rb:43:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/commonlogger.rb:20:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/showexceptions.rb:24:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/lint.rb:36:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/lint.rb:48:in `_call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in `synchronize'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `block in call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/head.rb:9:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.0/lib/rack/nulllogger.rb:9:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/rack/fiber_pool.rb:28:in `call'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/fiber_pool.rb:75:in `spawn'
/Users/nicklas/.rvm/gems/ruby-1.9.2-p290/gems/rack-fiber_pool-0.9.2/lib/fiber_pool.rb:75:in `resume'

-- 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

[1]    63579 abort      rackup -s thin app.rb

The crash actually happens when I request a URL. I posted a question on StackOverflow: http://stackoverflow.com/questions/8702948/fiber-pool-crashes-hard-when-using-thin

mperham commented 12 years ago

There's not much I can do about a C bug. Try 1.9.3.

ansman commented 12 years ago

I can't compile 1.9.3

So you're saying it's a problem with core ruby?

I've got a colleague that it works for, using the exact same setup. We think it has something to do with the the way we compiled ruby, it must be some difference then.

mperham commented 12 years ago

It's either a bug in MRI or a native gem. Pure ruby code should not be able to segmentation fault the VM.

It doesn't work out of the box but you can install 1.9.3 on OSX, just search around. I'm running it and it's quite fast and stable.

ansman commented 12 years ago

It works when using 1.9.3 if it's compiled with --with-gcc=clang in rvm, seems like it's XCode 4.2 that is messing stuff up.

mperham commented 12 years ago

Exactly right.

On Wed, Jan 4, 2012 at 2:01 PM, Nicklas Ansman Giertz reply@reply.github.com wrote:

It works when using 1.9.3 if it's compiled with --with-gcc=clang in rvm, seems like it's XCode 4.2 that is messing stuff up.