Project

General

Profile

Actions

Bug #11234

closed

RubyVM::InstructionSequence.load で case が落ちる

Added by yukimi_sake (Yukio Sakaue) almost 9 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-06-05 trunk 50775) [i386-mingw32]
[ruby-dev:49039]

Description

RubyVM::InstructionSequence.load を有効にしてテストしていますが、以下のコードで Segmentation fault になります。

str = <<EOS
def test_is()
  cond = "x"
  case cond
  when "x"
    p cond
  end
end
EOS

ar = RubyVM::InstructionSequence.compile(str).to_a
RubyVM::InstructionSequence.load(ar).eval
GC.start
test_is() #=>

<compiled>: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 <compiled>: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 `<main>'
<compiled>: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);
とすればエラーは起きなくなりますが、いかがでしょうか?
(一行だけなので、パッチは添付しません)

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

  • 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 22ea03bb7e213d60e49a9cdd1ec1b221ef802e2a), and the equivalent code with RubyVM::InstructionSequence.load_from_binary works correctly in ruby 2.3 and the master branch.

Actions

Also available in: Atom PDF

Like0
Like0