[#49078] DevelopersMeeting20150728Japan — SASADA Koichi <ko1@...>
Hi,
5 messages
2015/06/12
[ruby-dev:49039] [Ruby trunk - Bug #11234] [Open] RubyVM::InstructionSequence.load で case が落ちる
From:
yukimi_sake@...
Date:
2015-06-07 14:59:14 UTC
List:
ruby-dev #49039
Issue #11234 has been reported by Yukio Sakaue.
----------------------------------------
Bug #11234: RubyVM::InstructionSequence.load で case が落ちる
https://bugs.ruby-lang.org/issues/11234
* Author: Yukio Sakaue
* Status: Open
* Priority: Normal
* Assignee:
* 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 = <<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);
とすればエラーは起きなくなりますが、いかがでしょうか?
(一行だけなので、パッチは添付しません)
--
https://bugs.ruby-lang.org/