ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:49039] [Ruby trunk - Bug #11234] [Open] RubyVM::InstructionSequence.load で case が落ちる
       [not found] <redmine.issue-11234.20150607145913@ruby-lang.org>
@ 2015-06-07 14:59 ` yukimi_sake
  2019-07-05 22:31 ` [ruby-dev:50810] [Ruby master Bug#11234] " merch-redmine
  1 sibling, 0 replies; 2+ messages in thread
From: yukimi_sake @ 2015-06-07 14:59 UTC (permalink / raw)
  To: ruby-dev

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-dev:50810] [Ruby master Bug#11234] RubyVM::InstructionSequence.load で case が落ちる
       [not found] <redmine.issue-11234.20150607145913@ruby-lang.org>
  2015-06-07 14:59 ` [ruby-dev:49039] [Ruby trunk - Bug #11234] [Open] RubyVM::InstructionSequence.load で case が落ちる yukimi_sake
@ 2019-07-05 22:31 ` merch-redmine
  1 sibling, 0 replies; 2+ messages in thread
From: merch-redmine @ 2019-07-05 22:31 UTC (permalink / raw)
  To: ruby-dev

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 = <<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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-05 22:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11234.20150607145913@ruby-lang.org>
2015-06-07 14:59 ` [ruby-dev:49039] [Ruby trunk - Bug #11234] [Open] RubyVM::InstructionSequence.load で case が落ちる yukimi_sake
2019-07-05 22:31 ` [ruby-dev:50810] [Ruby master Bug#11234] " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).