[前][次][番号順一覧][スレッド一覧]

ruby-changes:50484

From: nobu <ko1@a...>
Date: Thu, 1 Mar 2018 09:37:51 +0900 (JST)
Subject: [ruby-changes:50484] nobu:r62617 (trunk): compile.c: fix load_from_binary

nobu	2018-03-01 09:37:47 +0900 (Thu, 01 Mar 2018)

  New Revision: 62617

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62617

  Log:
    compile.c: fix load_from_binary
    
    * compile.c (ibf_load_iseq_each): realpath may be nil.  follow up
      r59709.  [fix https://github.com/Shopify/bootsnap/issues/132]

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_iseq.rb
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 62616)
+++ test/ruby/test_iseq.rb	(revision 62617)
@@ -398,10 +398,9 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L398
 
   def test_to_binary_with_objects
     code = "[]"+100.times.map{|i|"<</#{i}/"}.join
-    bin = assert_nothing_raised {
-      RubyVM::InstructionSequence.compile(code).to_binary
-    }
-    # load_from_binary doesn't work now
-    assert_instance_of(String, bin)
+    iseq = RubyVM::InstructionSequence.compile(code)
+    bin = assert_nothing_raised {iseq.to_binary}
+    iseq2 = RubyVM::InstructionSequence.load_from_binary(bin)
+    assert_equal(iseq2.to_a, iseq.to_a)
   end
 end
Index: compile.c
===================================================================
--- compile.c	(revision 62616)
+++ compile.c	(revision 62617)
@@ -8708,7 +8708,8 @@ ibf_load_iseq_each(const struct ibf_load https://github.com/ruby/ruby/blob/trunk/compile.c#L8708
 		rb_raise(rb_eRuntimeError, "path object size mismatch");
 	    }
 	    path = rb_fstring(RARRAY_AREF(pathobj, 0));
-	    realpath = rb_fstring(RARRAY_AREF(pathobj, 1));
+	    realpath = RARRAY_AREF(pathobj, 1);
+	    if (!NIL_P(realpath)) realpath = rb_fstring(realpath);
 	}
 	else {
 	    rb_raise(rb_eRuntimeError, "unexpected path object");

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]