[#70843] Re: [ruby-cvs:58952] hsbt:r51801 (trunk): * lib/rubygems: Update to RubyGems HEAD(fe61e4c112). — Eric Wong <normalperson@...>
hsbt@ruby-lang.org wrote:
3 messages
2015/09/17
[ruby-core:70708] [Ruby trunk - Feature #8543] new rb_iseq_load crash
From:
billk@...
Date:
2015-09-09 23:27:29 UTC
List:
ruby-core #70708
Issue #8543 has been updated by B Kelly.
File iseq-load-test5.rb added
Subject changed from rb_iseq_load to new rb_iseq_load crash
Hi,
We've encountered a new crash related to RubyVM::InstructionSequence.load.
So far it has been reproducible on multiple platforms:
ruby 2.2.3p158 (2015-08-12 revision 48555) [i386-mswin32_100]
ruby 2.2.3p158 (2015-08-12 revision 51190) [i386-darwin13]
Attached is a small program which reproduces the crash on our systems.
(The attached file contains further details about the crash.)
----------------------------------------
Feature #8543: new rb_iseq_load crash
https://bugs.ruby-lang.org/issues/8543#change-54097
* Author: Alexey Voskov
* Status: Closed
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
I noticed an unusual behaviour of undocumented rb_iseq_load function.
Its work differs in different Ruby versions. I'm trying to protect some Ruby
source code by its conversion to YARV p-code and using the next strategy:
1. Convert code to array
~~~ruby
data = RubyVM::InstructionSequence.compile_file('hello.rb').to_a
~~~
2. Pass a compiled source to the rb_iseq_load function and evaluate it
~~~ruby
iseq = iseq_load.(data)
iseq.eval
~~~
Sample programs are supplied in the attachments.
"hello.rb"
```ruby
puts "tralivali"
def funct(a,b)
a**b
end
3.times { |i|
puts "Hello, world#{funct(2,i)}!"
}
```
The differences
Ruby 1.9.3 (ruby 1.9.3p194 (2012-04-20) [i386-mingw32])
Correct work. Output:
```
tralivali
Hello, world1!
Hello, world2!
Hello, world4!
```
Ruby 2.0.0 (ruby 2.0.0p193 (2013-05-14) [x64-mingw32])
Incorrect work (omits the code inside code blocks). Output
```
tralivali
```
Attempts of loading bigger programs by means of rb_iseq_load in Ruby 2.0.0 usually ends with a segmentation fault.
Such behaviour also can be reproduced by means of iseq Ruby extension ("for iseq freaks")
https://github.com/wanabe/iseq
P.S. I understand that it is an undocumented feature.
---Files--------------------------------
hello.rb (102 Bytes)
rb_pack.rb (931 Bytes)
iseq-load-test3.rb (210 Bytes)
iseq-load-test3-file.rb (369 Bytes)
please-fix-rb_iseq_load-thank-you.pdf (444 KB)
iseq-load-test5.rb (4.7 KB)
--
https://bugs.ruby-lang.org/