3

使用带有 FastCGI 的 Apache 访问我的 Redmine 安装时出现此类错误。这可能是什么原因?

/usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:454:in `read_length': undefined method `>>' for "\x0F":String (NoMethodError)
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:448:in `read_pair'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:441:in `parse_values'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:435:in `parse'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:195:in `read_record'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:126:in `next_request'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:116:in `session'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:104:in `each_request'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:36:in `each'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/rack-1.4.4/lib/rack/handler/fastcgi.rb:27:in `run'
        from /var/www/redmine/public/dispatch.fcgi:21:in `<main>'

错误中提到的行如下所示(带有行号),它是 fcgi.rg 文件的片段:

453   def self::read_length(buf)
454     if buf[0] >> 7 == 0
455     then buf.slice!(0,1)[0]
456     else buf.slice!(0,4).unpack('N')[0] & ((1<<31) - 1)
457     end
458   end

谢谢,马克

4

1 回答 1

1

Well, I don't know exactly what's going on, but the error itself is telling you that buf[0] is a String, and it doesn't respond to the bitwise shift operator (>>).

I'm not sure if this is 100% the correct way to debug this, but if you try to unpack that string, you get it's decimal value:

irb(main):053:0> "\x0F".unpack "c"
=> [15]

And if you look that up on http://www.asciitable.com/, apparently it's the "shift in" character. So somehow a "shift in" character is getting read by the buffer and when it tries to do a bitwise shift on that character, ruby is complaining.

I would check the file that it's processing and see if there are any suspect or illegal characters in there.

于 2013-02-05T17:35:04.060 回答