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 5D67219A079F for ; Thu, 10 Sep 2015 22:51:36 +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 A8430B5D91A for ; Thu, 10 Sep 2015 23:13:17 +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 5ED6E97A820 for ; Thu, 10 Sep 2015 23:13:20 +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 71E2495241E for ; Thu, 10 Sep 2015 23:13:16 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8DAB6120521; Thu, 10 Sep 2015 23:13:15 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 639701204C0 for ; Thu, 10 Sep 2015 23:13:07 +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=JFDkDjuz/8OBGA0/hJGI+9+Z9WA=; b=q/bDsfdyQ5KStPL7BE iVtNhOqNHG4OduLUzAWOXcIB7TwBIsMCoOsByrzs2Xxv6jZqc5RfJ1JOU4rnFOs2 7MBjqTOQv8sZzHA1ZpxluzfvembWGABkQrKQ60NCqFH50QNUbZodsPw40w7faHr2 wUn8bZU81H/S4u0U9/+98Kylg= Received: by filter0473p1mdw1.sendgrid.net with SMTP id filter0473p1mdw1.17307.55F18FE112 2015-09-10 14:12:49.329156737 +0000 UTC Received: from herokuapp.com (ec2-54-91-211-177.compute-1.amazonaws.com [54.91.211.177]) by ismtpd0006p1iad1.sendgrid.net (SG) with ESMTP id OXOwNHJOQQSkLSv8ecH-Rg for ; Thu, 10 Sep 2015 14:12:49.253 +0000 (UTC) Date: Thu, 10 Sep 2015 14:12:49 +0000 From: nagachika00@gmail.com 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: 45324 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 8543 X-Redmine-Issue-Author: alvoskov X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: nagachika X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6YjMXv2omxKvT8JQZyXjxMvsvxwpIeECC1BX ylePeKTpHHIDaw9oWtxgYlbezHXPGtUYZxj/EoLIHedCrvQu621vL6GWzbxwybVvb9xE53w5CLoFC/ 8gotlrn2JLE781PYaTKKCzgnEL+ePoVfnKMX X-SendGrid-Contentd-ID: {"test_id":"1441894371"} X-ML-Name: ruby-core X-Mail-Count: 70711 Subject: [ruby-core:70711] [Ruby trunk - Bug #8543] new rb_iseq_load crash 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 Tomoyuki Chikanaga. Tracker changed from Feature to Bug ruby -v set to - Backport set to 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED At least r51816 should be backported into 2.1/2.2. ---------------------------------------- Bug #8543: new rb_iseq_load crash https://bugs.ruby-lang.org/issues/8543#change-54101 * Author: Alexey Voskov * Status: Closed * Priority: Normal * Assignee: Koichi Sasada * ruby -v: - * Backport: 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: 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 ~~~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/