From: billk@... Date: 2014-10-09T23:44:17+00:00 Subject: [ruby-core:65574] [ruby-trunk - Feature #8543] rb_iseq_load Issue #8543 has been updated by B Kelly. Eric Wong wrote: > > Thanks for that data point, it was before I started mucking with iseq. > Can you try installing/running an older bison? Good call -- cygwin indeed allowed me to roll back to bison 2.7.x I wasn't able to fully automate `git bisect` as there was various build breakage on some of the commits (usually to do with changes in enc and enc/trans.) But ultimately, the result of the manual bisect was: 66d247bcb50a29769ff940100223544c125521aa is the first bad commit commit 66d247bcb50a29769ff940100223544c125521aa Author: ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Tue Apr 24 09:20:42 2012 +0000 * compile.c: fix to output warning when the same literals are available as a condition of same case clause. And remove infomation ('#n') because we can find duplicated condition with explicit line numbers. [ruby-core:38343] [Ruby 1.9 - Bug #5068] * test/ruby/test_syntax.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e :100644 100644 bcde6499fd43af4fc7eae9496d7eb529e52d5465 5f48bda3d2c5787acfc93c7d209964b45b4405bf M ChangeLog :100644 100644 508d599d081ddd3676efc513c25f76f00216116b 74982db138d5432f0077c49265e7b177a906ec97 M compile.c :040000 040000 b0608f2c1a2b0eaab543fb26ac4c2a78cb9b0c57 4f78f071cacaf4c8da9d8ccfecb027092f94bc54 M test My test script was running both Alexey Voskov's "tralivali" test as well as my segfault test relating to the case statement. I suspect the above commit is what introduced the case statement- related segfault. I'm not sure if it will also relate to Alexey Voskov's "tralivali" test well, or whether that might be a separate issue. (But if the above can be fixed, I'm happy to try another bisect if other issues remain.) Thanks & Regards, Bill ---------------------------------------- Feature #8543: rb_iseq_load https://bugs.ruby-lang.org/issues/8543#change-49325 * Author: Alexey Voskov * Status: Open * Priority: Low * Assignee: Koichi Sasada * Category: YARV * Target version: current: 2.2.0 ---------------------------------------- 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) -- https://bugs.ruby-lang.org/