From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 9061817D062F for ; Thu, 20 Jun 2013 17:06:51 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id EF0D6EA6A9A for ; Thu, 20 Jun 2013 16:40:33 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 26AF497A82B for ; Thu, 20 Jun 2013 16:40:34 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PMF6ZKXuSCiY for ; Thu, 20 Jun 2013 16:40:34 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E043E97A820 for ; Thu, 20 Jun 2013 16:40:33 +0900 (JST) Received: from carbon.ruby-lang.org (carbon.ruby-lang.org [221.186.184.68]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 863CE95241A for ; Thu, 20 Jun 2013 16:40:31 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by carbon.ruby-lang.org (Postfix) with ESMTP id E2B8D3C21E318; Thu, 20 Jun 2013 16:40:29 +0900 (JST) Received: from fluorine.ruby-lang.org (www.rubyist.net [210.251.121.216]) by carbon.ruby-lang.org (Postfix) with ESMTP id 8A6863C21F753 for ; Thu, 20 Jun 2013 16:40:29 +0900 (JST) Received: from ruby-lang.org (localhost [127.0.0.1]) by fluorine.ruby-lang.org (Postfix) with ESMTP id 60D963F85A for ; Thu, 20 Jun 2013 16:40:29 +0900 (JST) Delivered-To: ruby-core@ruby-lang.org Date: Thu, 20 Jun 2013 16:40:29 +0900 Posted: Thu, 20 Jun 2013 16:40:28 +0900 From: "nagachika (Tomoyuki Chikanaga)" Reply-To: ruby-core@ruby-lang.org Subject: [ruby-core:55568] [ruby-trunk - Bug #8543] rb_iseq_load To: ruby-core@ruby-lang.org Message-Id: References: X-ML-Name: ruby-core X-Mail-Count: 55568 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-core-ctl@ruby-lang.org; help= X-Mailer: Redmine X-Redmine-Issue-Author: alvoskov X-Redmine-Issue-Assignee: ko1 X-Auto-Response-Suppress: OOF X-Redmine-Issue-Id: 8543 X-Redmine-Mailinglistintegration-Message-Ids: 28972 X-Redmine-Project: ruby-trunk Auto-Submitted: auto-generated X-Redmine-Site: Ruby Issue Tracking System X-Redmine-Host: bugs.ruby-lang.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Precedence: bulk List-Id: ruby-core.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: Issue #8543 has been updated by nagachika (Tomoyuki Chikanaga). Priority changed from Normal to Low Backport set to 1.9.3: DONTNEED, 2.0.0: REQUIRED ruby -v set to ruby 2.0.0p234 (2013-06-19 revision 41434) [x86_64-darwin11.4.2] ---------------------------------------- Bug #8543: rb_iseq_load https://bugs.ruby-lang.org/issues/8543#change-40062 Author: alvoskov (Alexey Voskov) Status: Open Priority: Low Assignee: ko1 (Koichi Sasada) Category: YARV Target version: current: 2.1.0 ruby -v: ruby 2.0.0p234 (2013-06-19 revision 41434) [x86_64-darwin11.4.2] Backport: 1.9.3: DONTNEED, 2.0.0: REQUIRED 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 data = RubyVM::InstructionSequence.compile_file('hello.rb').to_a 2) Pass a compiled source to the rb_iseq_load function and evaluate it iseq = iseq_load.(data) iseq.eval Sample programs are supplied in the attachments. "hello.rb" --------------------------- 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. -- http://bugs.ruby-lang.org/