MacRuby on Rails #20110314-1
Assertion failed: *1, function pop_current_exception, file vm.cpp, line 3434.
エラーが発生しているのはvm.cppの以下の関数。
void RoxorVM::pop_current_exception(int pos) { RoxorSpecialException *sexc = get_special_exc(); if (sexc != NULL) { return; } assert((size_t)pos < current_exceptions.size()); std::vector<VALUE>::iterator iter = current_exceptions.end() - (pos + 1); VALUE exc = *iter; current_exceptions.erase(iter); GC_RELEASE(exc); //printf("POP (%d) %p %s\n", pos, (void *)exc, RSTRING_PTR(rb_inspect(exc))); }
コアダンプさせて、gdbなどでおっかける。
$ ulimit -c unlimited $ macruby -S rails generate scaffold Bookmark title:string description:text url:string (以下、実行結果) Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3434. zsh: abort (core dumped) macruby -S rails generate scaffold Bookmark title:string description:text $ ulimit -c $ ls -l /cores (以下、実行結果。MBPにメモリを8GB積んでいるのでコアが8GBになっている。) 合計 8.4G -r-------- 1 kouji admin 8.4G 2011-03-12 13:14 core.79761 $ gdb -c /cores/core.79761 (以下、実行結果) ... #0 0x00007fff85649616 in __kill () (gdb) bt #0 0x00007fff85649616 in __kill () #1 0x00007fff856e9cca in abort () #2 0x00007fff856d6c90 in __assert_rtn () #3 0x0000000100156b83 in rb_vm_thread_pre_init () #4 0x0000000100fef88c in MREP_F2E1FABE962645EA8AD1A1658528659E () #5 0x000000010014e5bd in rb_vm_dispatch () #6 0x0000000102d5a5b6 in ?? () #7 0x0000000102d5ad1e in ?? () #8 0x0000000100165db3 in rb_vm_run () #9 0x00000001000497d1 in rb_load () #10 0x000000010004984b in rb_load () #11 0x000000010015f51a in rb_rescue2 () #12 0x0000000100049fe7 in rb_require_safe () #13 0x000000010014e5bd in rb_vm_dispatch () #14 0x0000000102d5a5b6 in ?? () #15 0x0000000102d5a19a in ?? () #16 0x0000000100165db3 in rb_vm_run () #17 0x0000000100041230 in ruby_run_node () #18 0x0000000100000d28 in main ()
もう少し詳しく調べたいので-g -O0でコンパイルしてからcoreをbtした。
$ gdb -c /cores/core.88901 ... (gdb) bt #0 0x00007fff85649616 in __kill () #1 0x00007fff856e9cca in abort () #2 0x00007fff856d6c90 in __assert_rtn () #3 0x000000010014bfea in rb_vm_unregister_finalizer () #4 0x0000000100156969 in rb_vm_pop_exception () #5 0x0000000102f2c87c in MREP_66AE2600EA4147B4A0649110BF7392B4 () #6 0x000000010013cdce in rb_vm_dispatch () #7 0x0000000102d5a5b6 in ?? () #8 0x0000000102d5ad1e in ?? () #9 0x00000001001573d6 in rb_vm_run () #10 0x0000000100041eec in rb_load () #11 0x0000000100042457 in rb_f_require () #12 0x0000000100155e98 in rb_rescue2 () #13 0x0000000100042584 in rb_require_safe () #14 0x0000000100041f72 in rb_f_require () #15 0x0000000100041f95 in rb_f_require () #16 0x000000010013cdce in rb_vm_dispatch () #17 0x0000000102d5a5b6 in ?? () #18 0x0000000102d5a19a in ?? () #19 0x00000001001573d6 in rb_vm_run () #20 0x00000001000396fc in ruby_run_node () #21 0x0000000100000c15 in main ()
Cレベルのbtではよく分からなかったのでRubyレベルのバックトレースを出力させてみる。
scaffoldとserverは同じ場所でエラーになっているように見える。
$ macruby -S rails generate scaffold Bookmark title:string description:text url:string (以下、実行結果) /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:4:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:4:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:268:in `configure_gem_home_and_path' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:78:in `configure' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:134:in `definition' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:124:in `load' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:107:in `setup' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' pos: 0, current_exceptions.size(): 0 /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3439. zsh: abort macruby -S rails generate scaffold Bookmark title:string description:text $ macruby -S rails server (以下、実行結果) /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/local/bin/rails:9:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:4:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:4:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:268:in `configure_gem_home_and_path' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:78:in `configure' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:134:in `definition' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:124:in `load' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:107:in `setup' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' pos: 0, current_exceptions.size(): 0 /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>' Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3439. zsh: abort macruby -S rails server
上記のバックトレースのうち、以下の部分があやしい。コードを見てみる。
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:268:in `configure_gem_home_and_path' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:78:in `configure' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:134:in `definition' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:124:in `load' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:107:in `setup' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:6:in `<main>'
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:268:in `configure_gem_home_and_path'
def configure_gem_home_and_path if settings[:disable_shared_gems] ENV['GEM_PATH'] = '' ENV['GEM_HOME'] = File.expand_path(bundle_path, root) elsif Gem.dir != bundle_path.to_s paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? } ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) ENV["GEM_HOME"] = bundle_path.to_s end FileUtils.mkdir_p bundle_path.to_s # <= 268行目 Gem.clear_paths end
bundle_path.to_sは"/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2"であり、作成済み。上記のバックトレースは、FileUtils.mkdir_pの処理中にディレクトリ作成済みかどうかをチェックしているだけであった。
手がかりが以下だけ。
pos: 0, current_exceptions.size(): 0 /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Users/kouji/work/MacRuby/work/demo/script/rails:5:in `<main>'
「$ macruby -S rails」、そして「$ macruby config/boot.rb」で再現できる。config/boot.rbでrequireしている"/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb"を追ってみる。
$ sudo chmod -R a+w /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10
$ macruby config/boot.rb /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:1:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' 1 3 6 /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:7:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:6:in `<main>' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:7:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' 8 10 /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:268:in `configure_gem_home_and_path' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:78:in `configure' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:134:in `definition' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:124:in `load' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb:107:in `setup' /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/setup.rb:11:in `<main>' /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' 12 25 27 29 pos: 0, current_exceptions.size(): 0 /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3439. zsh: abort macruby config/boot.rb
29行はsetup.rbの最後の行である。最後まで処理が終わってからエラーになっ
ている。finalizer関係なのだろうか。
どこまで処理するとエラーになるか確認した。Bundler.setupを実行するとエラーになる。
require 'bundler/shared_helpers' if Bundler::SharedHelpers.in_bundle? require 'bundler' begin Bundler.setup # <= ここを処理するとエラーになる。 rescue Bundler::BundlerError => e puts "\e[31m#{e.message}\e[0m" puts e.backtrace.join("\n") if ENV["DEBUG"] exit e.status_code end # Add bundler to the load path after disabling system gems bundler_lib = File.expand_path("../..", __FILE__) $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib) end
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler.rb
@setup = load.setup # <= ここのsetupを処理するとエラーになる。loadだけだとエラーにならない。
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/runtime.rb
specs = groups.any? ? @definition.specs_for(groups) : requested_specs # <= ここのrequested_specsを処理するとエラーになる。
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/definition.rb
def requested_specs @requested_specs ||= begin groups = self.groups - Bundler.settings.without groups.map! { |g| g.to_sym } specs_for(groups) # <= ここを処理するとエラーになる。groupsの値は[:default]であった。 end end
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/definition.rb
def specs_for(groups) deps = dependencies.select { |d| (d.groups & groups).any? } deps.delete_if { |d| !d.should_include? } specs.for(expand_dependencies(deps)) # <= ここのspecsを処理するとエラーになる。 end
depsの値
[<Bundler::Dependency type=:runtime name="rails" requirements="= 3.0.5">, <Bundler::Dependency type=:runtime name="sqlite3" requirements=">= 0">]
expand_dependencies(deps)の値
[#<Bundler::DepProxy:0x2004f0ae0 @dep=<Bundler::Dependency type=:runtime name="rails" requirements="= 3.0.5"> @__platform="ruby" @required_by=[]>, #<Bundler::DepProxy:0x200615740 @dep=<Bundler::Dependency type=:runtime name="sqlite3" requirements=">= 0"> @__platform="ruby" @required_by=[]>]
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/definition.rb
def specs @specs ||= begin specs = resolve.materialize(requested_dependencies) # <= ここのresolveを処理するとエラーになる。requested_dependenciesだけなら問題ない。 unless specs["bundler"].any? local = Bundler.settings[:frozen] ? rubygems_index : index bundler = local.search(Gem::Dependency.new('bundler', VERSION)).last specs["bundler"] = bundler if bundler end specs end end
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/bundler-1.0.10/lib/bundler/definition.rb
def resolve @resolve ||= begin if Bundler.settings[:frozen] @locked_specs else last_resolve = converge_locked_specs source_requirements = {} dependencies.each do |dep| next unless dep.source source_requirements[dep.name] = dep.source.specs end # Run a resolve against the locally available gems last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve) # <= ここのResolver.resolveを処理するとエラーになる。 end end end
$ env DEBUG_RESOLVER=1 macruby config/boot.rb ==== Iterating ==== Activated: rails (3.0.5) railties (3.0.5) thor (0.14.6) actionmailer (3.0.5) mail (2.2.15) treetop (1.4.9) polyglot (0.3.1) activesupport (3.0.5) actionpack (3.0.5) mime-types (1.16) activeresource (3.0.5) rack-mount (0.6.13) rack (1.2.1) activemodel (3.0.5) bundler (1.0.10) rack-test (0.5.7) erubis (2.6.6) abstract (1.0.0) sqlite3 (1.3.3) rake (0.8.7) i18n (0.5.0) builder (2.1.2) activerecord (3.0.5) tzinfo (0.3.24) Requirements: arel (~> 2.0.2) Attempting: arel (~> 2.0.2) Activating: arel (2.0.9) * rails (= 3.0.5) * activerecord (= 3.0.5) * arel (~> 2.0.2) Dependencies pos: 0, current_exceptions.size(): 0 /Users/kouji/work/MacRuby/work/demo/config/boot.rb:6:in `<main>' Assertion failed: ((size_t)pos < current_exceptions.size()), function pop_current_exception, file vm.cpp, line 3439. zsh: abort env DEBUG_RESOLVER=1 macruby config/boot.rb
arelに何か関係があるのだろうか。
ruby19trunkでの実行結果は以下。
cymric$ env DEBUG_RESOLVER=1 ruby19trunk config/boot.rb ==== Iterating ==== Activated: rails (3.0.5) sqlite3 (1.3.3) actionmailer (3.0.5) actionpack (3.0.5) activesupport (3.0.5) builder (2.1.2) railties (3.0.5) rack-mount (0.6.13) activeresource (3.0.5) activerecord (3.0.5) thor (0.14.6) rack (1.2.1) rack-test (0.5.7) bundler (1.0.10) rake (0.8.7) activemodel (3.0.5) erubis (2.6.6) i18n (0.5.0) tzinfo (0.3.24) mail (2.2.15) abstract (1.0.0) arel (2.0.9) mime-types (1.16) treetop (1.4.9) Requirements: polyglot (>= 0.3.1) Attempting: polyglot (>= 0.3.1) Activating: polyglot (0.3.1) * rails (= 3.0.5) * actionmailer (= 3.0.5) * mail (~> 2.2.15) * treetop (~> 1.4.8) * polyglot (>= 0.3.1) Dependencies
この後もいろいろ調べたが、よく分からなかった。とりあえず以下のようにし
て、例外がraiseされていないのに例外をpopしようとしたときにログだけ出力
するようにして無視するように修正しておく。
diff --git a/vm.cpp b/vm.cpp index aa2fac1..fc0e03f 100644 --- a/vm.cpp +++ b/vm.cpp @@ -3423,6 +3423,53 @@ RoxorVM::push_current_exception(VALUE exc) //printf("PUSH %p %s\n", (void *)exc, RSTRING_PTR(rb_inspect(exc))); } +extern "C" +VALUE +rb_vm_print_backtrace(int skip) +{ + assert(skip >= 0); + + void *callstack[128]; + int callstack_n = backtrace(callstack, 128); + + // TODO should honor level + + VALUE ary = rb_ary_new(); + + unsigned int interpreter_frame_idx = 0; + + for (int i = 0; i < callstack_n; i++) { + char path[PATH_MAX]; + char name[100]; + unsigned long ln = 0; + + path[0] = name[0] = '\0'; + + if (GET_CORE()->symbolize_call_address(callstack[i], path, sizeof path, + &ln, name, sizeof name, &interpreter_frame_idx) + && name[0] != '\0' && path[0] != '\0') { + char entry[PATH_MAX]; + if (ln == 0) { + snprintf(entry, sizeof entry, "%s:in `%s'", + path, name); +printf("%s:in `%s'\n", path, name); + } + else { + snprintf(entry, sizeof entry, "%s:%ld:in `%s'", + path, ln, name); +printf("%s:%ld:in `%s'\n", path, ln, name); + } + rb_ary_push(ary, rb_str_new2(entry)); + } + } + + while (skip-- > 0) { + rb_ary_shift(ary); + } + + return ary; +} + void RoxorVM::pop_current_exception(int pos) { @@ -3431,6 +3478,12 @@ RoxorVM::pop_current_exception(int pos) return; } +if ((size_t)pos >= current_exceptions.size()) { + printf("pos: %d, current_exceptions.size(): %d\n", pos, (int)current_exceptions.size()); + rb_vm_print_backtrace(0); + debug_exceptions(); + return; +} assert((size_t)pos < current_exceptions.size()); std::vector<VALUE>::iterator iter = current_exceptions.end() - (pos + 1);
メモ
coreをはかせずにgdbでMacRubyのデバッグをする。
env DYLD_LIBRARY_PATH=/Users/kouji/work/MacRuby/MacRuby gdb --args /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/bin/macruby config/boot.rb
参考情報
Technical Note TN2124 -Mac OS X Debugging Magic-: http://developer.apple.com/jp/technotes/tn2124.html
*1:size_t)pos < current_exceptions.size(