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 6EBCF17D6B34 for ; Wed, 16 Apr 2014 17:21:44 +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 3F6E8B5D8AF for ; Wed, 16 Apr 2014 17:25:57 +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 5001897A82C for ; Wed, 16 Apr 2014 17:25:59 +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 GfB3YgvZcTVl for ; Wed, 16 Apr 2014 17:25:58 +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 CFECE97A82B for ; Wed, 16 Apr 2014 17:25:58 +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 9B0B995241E for ; Wed, 16 Apr 2014 17:25:56 +0900 (JST) Received: from [221.186.184.76] (unknown [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7BF9812045A; Wed, 16 Apr 2014 17:25:55 +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 SMTP id E288A120400 for ; Wed, 16 Apr 2014 17:25:51 +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=B/+OWCerms9JEupHgsTOnrwkwWk=; b=BH5lI7Q+VvewHXADNq CefEeP8FZ9+2XsK1a6fdgapMQxaYNV4g7Z5n5lLm5Y1WdkriVQfukvFpN9HLqBUf iBCxlkWYaMhNwU15pGy6/9eXMaaT2nP0Q3tJ/tva7Gw3qpJL9VQTy2f01DVIxFrx YgI4U/4KpQjNudQLMN3O1KyJ4= Received: by mf175.sendgrid.net with SMTP id mf175.38713.534E3E8E4 Wed, 16 Apr 2014 08:25:50 +0000 (UTC) Received: from herokuapp.com (ec2-54-221-163-227.compute-1.amazonaws.com [54.221.163.227]) by ismtpd-024 (SG) with ESMTP id 14569a45b46.60f5.6794e for ; Wed, 16 Apr 2014 08:25:50 +0000 (GMT) Date: Wed, 16 Apr 2014 08:25:49 +0000 From: billk@cts.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: 35921 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 8543 X-Redmine-Issue-Author: alvoskov X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: spatulasnout 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS70gup4Cgp8fEV9h3H6k4ISOhFIvvxfoBfOMyKweIvN3JALRFNJDE6z+jVagupYkGE+YnyyjkJBdwZEtM4ze3noiWo+EaWjl54Qi3va0Pm+h5XqYXFtCmLhGJ44XeCHm1w= X-ML-Name: ruby-core X-Mail-Count: 62050 Subject: [ruby-core:62050] [ruby-trunk - Bug #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 B Kelly. Hi, Just a data point: With ruby 2.2.0dev (2014-04-16 trunk 45576) [i386-mswin32_100], the rb_iseq_load example in https://bugs.ruby-lang.org/issues/8543 is producing the correct output. (I will attempt to test with more complicated programs soon.) Regards, Bill ---------------------------------------- Bug #8543: rb_iseq_load https://bugs.ruby-lang.org/issues/8543#change-46226 * Author: Alexey Voskov * Status: Open * Priority: Low * Assignee: Koichi Sasada * Category: YARV * Target version: current: 2.2.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. ---Files-------------------------------- hello.rb (102 Bytes) rb_pack.rb (931 Bytes) -- https://bugs.ruby-lang.org/