From: merch-redmine@... Date: 2019-07-05T22:31:02+00:00 Subject: [ruby-dev:50810] [Ruby master Bug#11234] RubyVM::InstructionSequence.load で case が落ちる Issue #11234 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed I think this can be closed. It doesn't look like 2.3 actually shipped with `RubyVM::InstructionSequence.load` (disabled at commit:22ea03bb7e213d60e49a9cdd1ec1b221ef802e2a), and the equivalent code with `RubyVM::InstructionSequence.load_from_binary` works correctly in ruby 2.3 and the master branch. ---------------------------------------- Bug #11234: RubyVM::InstructionSequence.load で case が落ちる https://bugs.ruby-lang.org/issues/11234#change-79141 * Author: yukimi_sake (Yukio Sakaue) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.3.0dev (2015-06-05 trunk 50775) [i386-mingw32] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: REQUIRED ---------------------------------------- RubyVM::InstructionSequence.load を有効にしてテストしていますが、以下のコードで Segmentation fault になります。 ~~~ str = < :3: [BUG] Segmentation fault ruby 2.3.0dev (2015-06-05 trunk 50775) [i386-mingw32] -- Control frame information ----------------------------------------------- c:0003 p:0016 s:0011 e:000009 METHOD :3 c:0002 p:0060 s:0006 E:00002c EVAL E:/testdir/iseqtest.rb:14 [FINISH] c:0001 p:0000 s:0002 E:000d0c (none) [FINISH] -- Ruby level backtrace information ---------------------------------------- E:/testdir/iseqtest.rb:14:in `
' :3:in `test_is' ... ~~~ このコードを to_a => load すると case のブランチリストを Hash にして opt_case_dispatch に渡しますが、compile.c の 6040行目 iseq_build_from_ary_body() 内で、 iseq_add_mark_object_compile_time(iseq, map); を使っているため、コンパイル後 GC をかけると、この Hash(map) が捨てられてしまうせいだと思います。 iseq_add_mark_object(iseq, map); とすればエラーは起きなくなりますが、いかがでしょうか? (一行だけなので、パッチは添付しません) -- https://bugs.ruby-lang.org/