Updated lib/psych.rb #54

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@noverloop

Recent modification broke postrank-uri's yaml reading, DocumentStream's parse-method takes a single argument.
I applied the fix locally and the bug was resolved.

@noverloop noverloop Updated lib/psych.rb
Recent modification broke postrank-uri's yaml reading, Streams take single argument.
I applied the fix locally and the bug was resolved
97b9e45
@tenderlove
Member

Can you show me some code to reproduce the problem? I don't want to apply this patch without a test or repro code. Thanks.

@michaeleconomy

would this cause this?

[ pid=29437 thr=57456640 file=utils.rb:176 time=2012-03-28 17:22:52.993 ]: *** Exception ArgumentError in PhusionPassenger::Rack::ApplicationSpawner (wrong number of arguments(2 for 1)) (process 29437, thread #Thread:0x00000006d97000):
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:203:in parse' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:203:inparse_stream'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:151:in parse' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:127:inload'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:297:in block in load_file' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:297:inopen'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/psych-1.3.1/lib/psych.rb:297:in load_file' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/geoip-1.1.1/lib/geoip.rb:64:inclass:GeoIP'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/geoip-1.1.1/lib/geoip.rb:54:in <top (required)>' from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:inrequire'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in block (2 levels) in require' from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:ineach'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in block in require' from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:ineach'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in require' from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler.rb:119:inrequire'
from /home/goodreads/releases/20120329000621/config/application.rb:17:in <top (required)>' from /home/goodreads/releases/20120329000621/config/environment.rb:2:inrequire'
from /home/goodreads/releases/20120329000621/config/environment.rb:2:in <top (required)>' from config.ru:3:inrequire'
from config.ru:3:in block in <main>' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:ininstance_eval'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in initialize' from config.ru:1:innew'
from config.ru:1:in <main>' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:225:ineval'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:225:in load_rack_app' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:157:inblock in initialize_server'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb:572:in report_app_init_status' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:154:ininitialize_server'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:204:in start_synchronously' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:180:instart'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:129:in start' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:253:inblock (2 levels) in spawn_rack_application'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:132:in lookup_or_add' from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:246:inblock in spawn_rack_application'
from /home/goodreads/shared/bundle/ruby/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'

@noverloop

The error does indeed happen when Bundler requires the gems in the gemfile.
gem 'psych'
gem 'postrank-uri'

If you look at what exactly goes wrong inside the postrank_uri gem, then it's because it loads an internationalization yaml file embedded in the gem.
This is the line in the postrank gem that causes it:


Regards

@tddium
tddium commented Apr 20, 2012

This bug prevents bundler from working when there is a non-trivial ~/.gemrc. Consider the code at line 203 in lib/psych.rb and the test case attached below which produces this output:

#<Psych::Nodes::Stream:0x8fe894c @children=[#<Psych::Nodes::Document:0x8fe88fc @children=[#<Psych::Nodes::Scalar:0x8fe88c0 @value="a", @anchor=nil, @tag=nil, @plain=true, @quoted=false, @style=1>], @version=[], @tag_directives=[], @implicit=false, @implicit_end=true>], @encoding=1>
#<ArgumentError: wrong number of arguments (2 for 1)>
#<ArgumentError: wrong number of arguments (2 for 1)>
  def self.parse_stream yaml, filename = nil, &block
    if block_given?
      parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
      parser.parse yaml, filename
    else
      parser = self.parser
      parser.parse yaml, filename
      parser.handler.root
    end
  end
require 'psych'

yaml = "--- a\n"

s = Psych.parse_stream yaml
puts s.inspect

begin
  Psych.parse_stream yaml, 'filename'
rescue Exception => e
  $stderr.puts e.inspect
end

begin
  Psych.parse_stream yaml, 'filename' do
  end
rescue Exception => e
  $stderr.puts e.inspect
end
@tenderlove
Member

@tddium the current release of psych allows 2 arguments to parse_stream as well as to the parse method on the parser. I believe that an older version of psych C code is being loaded along side of a newer version of the ruby part of psych. I cannot fix this until someone can send me a way to reproduce the problem.

I'm closing this as there is no test case, and it doesn't actually fix the problem. Please track issue #61 where we are trying to find the actual cause of this issue. Thanks!

@tenderlove tenderlove closed this May 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment