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 3110417DCA6F for ; Sat, 22 Nov 2014 17:38:44 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id C3BDBB5D918 for ; Sat, 22 Nov 2014 17:28:39 +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 C5DFB97A826 for ; Sat, 22 Nov 2014 17:28:41 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me 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 3LyrYhOwqZPV for ; Sat, 22 Nov 2014 17:28:41 +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 625F797A820 for ; Sat, 22 Nov 2014 17:28:41 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id ACE6995241B for ; Sat, 22 Nov 2014 17:28:38 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1F26C1204B3; Sat, 22 Nov 2014 17:28:35 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 2A43812049C for ; Sat, 22 Nov 2014 17:28:30 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=6RvcpQdeLPBGJ3FU2A+jrUQ8myM=; b=Br1Od9/WhgsoQh/zRL YpVo9hlmOL+bA/x5LxinoTpt4n548qragi4xFVbwNtSn/NLlVu97mInY7AB3/rz2 uofExvNjPI6HOXIDNzI16cFdoP/JD2gQdMhmViEbVuFdiPKgKPFXTIfukDAHtidL 6pb08H4Oo0bvFLjanMJDYM/p4= Received: by filter0220p1mdw1.sendgrid.net with SMTP id filter0220p1mdw1.21515.5470492911 2014-11-22 08:28:27.23533846 +0000 UTC Received: from herokuapp.com (ec2-54-81-154-168.compute-1.amazonaws.com [54.81.154.168]) by ismtpd-014 (SG) with ESMTP id 149d69dd0aa.5619.35fe21 for ; Sat, 22 Nov 2014 08:28:27 +0000 (UTC) Date: Sat, 22 Nov 2014 08:28:27 +0000 From: normalperson@yhbt.net To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 40796 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 8543 X-Redmine-Issue-Author: alvoskov X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: normalperson X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: OOF Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6/4qCloznoCHql4eBkMBGrT6nWw87OvbsErY Nlwc2DtnqD3FVdDNGw0h5TbR06kw0I6VlvT7cgv2At43oRihXn5op3RM29wlFb7qmIS3DZscAOy8C0 KMWvgP7zjLPi2I7kumkn0WbbjERXJwPpSLwf X-ML-Name: ruby-core X-Mail-Count: 66410 Subject: [ruby-core:66410] [ruby-trunk - Feature #8543] rb_iseq_load X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #8543 has been updated by Eric Wong. billk@cts.com wrote: > But ultimately, the result of the manual bisect was: > > 66d247bcb50a29769ff940100223544c125521aa is the first bad commit > commit 66d247bcb50a29769ff940100223544c125521aa > Author: ko1 > 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. That was only one of the breakages :) Things have bitrotted a lot over the years. The following patch might be ready to commit to trunk: http://80x24.org/spew/m/rb_iseq_load_fix@v1.txt It's better than the complete breakage we have right now, so I might commit the above in a few days. The new test case I added should help (or force) other core committers to maintain iseq loading, though. There's no public API change in this version of my patch. The test cases are probably not complete, though. I am mainly interested in the feature because I'm working on another (in-core) optimization which may utilize this. I can definitely use some help thinking of better test cases since I don't believe I remember all of Ruby syntax :x ---------------------------------------- Feature #8543: rb_iseq_load https://bugs.ruby-lang.org/issues/8543#change-50047 * 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/