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

ruby-changes:34427

From: usa <ko1@a...>
Date: Mon, 23 Jun 2014 16:52:56 +0900 (JST)
Subject: [ruby-changes:34427] usa:r46508 (ruby_2_0_0): merge revision(s) 45291, 45299, 45314, 45325: [Backport #9599]

usa	2014-06-23 16:52:37 +0900 (Mon, 23 Jun 2014)

  New Revision: 46508

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

  Log:
    merge revision(s) 45291,45299,45314,45325: [Backport #9599]
    
    * ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free),
      ext/fiddle/handle.c (fiddle_handle_free),
      ext/fiddle/pointer.c (fiddle_ptr_free): fix memory leak.
      based on the patch Heesob Park at [ruby-dev:48021] [Bug #9599].

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/dl/cptr.c
    branches/ruby_2_0_0/ext/dl/handle.c
    branches/ruby_2_0_0/ext/fiddle/handle.c
    branches/ruby_2_0_0/ext/fiddle/pointer.c
    branches/ruby_2_0_0/test/dl/test_cptr.rb
    branches/ruby_2_0_0/test/dl/test_handle.rb
    branches/ruby_2_0_0/test/fiddle/test_handle.rb
    branches/ruby_2_0_0/test/fiddle/test_pointer.rb
    branches/ruby_2_0_0/test/ruby/envutil.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46507)
+++ ruby_2_0_0/ChangeLog	(revision 46508)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Jun 23 16:45:48 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free),
+	  ext/fiddle/handle.c (fiddle_handle_free),
+	  ext/fiddle/pointer.c (fiddle_ptr_free): fix memory leak.
+	  based on the patch Heesob Park at [ruby-dev:48021] [Bug #9599].
+
 Wed May 28 13:24:39 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (rb_cv_func___builtin_unreachable): try with an
Index: ruby_2_0_0/ext/dl/cptr.c
===================================================================
--- ruby_2_0_0/ext/dl/cptr.c	(revision 46507)
+++ ruby_2_0_0/ext/dl/cptr.c	(revision 46508)
@@ -49,6 +49,7 @@ dlptr_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/dl/cptr.c#L49
 	    (*(data->free))(data->ptr);
 	}
     }
+    xfree(ptr);
 }
 
 static size_t
Index: ruby_2_0_0/ext/dl/handle.c
===================================================================
--- ruby_2_0_0/ext/dl/handle.c	(revision 46507)
+++ ruby_2_0_0/ext/dl/handle.c	(revision 46508)
@@ -38,6 +38,7 @@ dlhandle_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/dl/handle.c#L38
     if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
 	dlclose(dlhandle->ptr);
     }
+    xfree(ptr);
 }
 
 static size_t
Index: ruby_2_0_0/ext/fiddle/pointer.c
===================================================================
--- ruby_2_0_0/ext/fiddle/pointer.c	(revision 46507)
+++ ruby_2_0_0/ext/fiddle/pointer.c	(revision 46508)
@@ -65,6 +65,7 @@ fiddle_ptr_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/fiddle/pointer.c#L65
 	    (*(data->free))(data->ptr);
 	}
     }
+    xfree(ptr);
 }
 
 static size_t
Index: ruby_2_0_0/ext/fiddle/handle.c
===================================================================
--- ruby_2_0_0/ext/fiddle/handle.c	(revision 46507)
+++ ruby_2_0_0/ext/fiddle/handle.c	(revision 46508)
@@ -40,6 +40,7 @@ fiddle_handle_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/fiddle/handle.c#L40
     if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){
 	dlclose(fiddle_handle->ptr);
     }
+    xfree(ptr);
 }
 
 static size_t
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46507)
+++ ruby_2_0_0/version.h	(revision 46508)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-05-28"
-#define RUBY_PATCHLEVEL 490
+#define RUBY_RELEASE_DATE "2014-06-23"
+#define RUBY_PATCHLEVEL 491
 
 #define RUBY_RELEASE_YEAR 2014
-#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 28
+#define RUBY_RELEASE_MONTH 6
+#define RUBY_RELEASE_DAY 23
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/envutil.rb
===================================================================
--- ruby_2_0_0/test/ruby/envutil.rb	(revision 46507)
+++ ruby_2_0_0/test/ruby/envutil.rb	(revision 46508)
@@ -340,7 +340,7 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/envutil.rb#L340
         assert_warning(*args) {$VERBOSE = false; yield}
       end
 
-      def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false)
+      def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, rss: false)
         require_relative 'memory_status'
         token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
         token_dump = token.dump
Index: ruby_2_0_0/test/fiddle/test_pointer.rb
===================================================================
--- ruby_2_0_0/test/fiddle/test_pointer.rb	(revision 46507)
+++ ruby_2_0_0/test/fiddle/test_pointer.rb	(revision 46508)
@@ -230,5 +230,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/fiddle/test_pointer.rb#L230
       assert_raise(DLError) {nullpo[0]}
       assert_raise(DLError) {nullpo[0] = 1}
     end
+
+    def test_no_memory_leak
+      assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Pointer.allocate}', rss: true)
+    end
   end
 end if defined?(Fiddle)
Index: ruby_2_0_0/test/fiddle/test_handle.rb
===================================================================
--- ruby_2_0_0/test/fiddle/test_handle.rb	(revision 46507)
+++ ruby_2_0_0/test/fiddle/test_handle.rb	(revision 46508)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/fiddle/test_handle.rb#L1
 begin
   require_relative 'helper'
+  require_relative '../ruby/envutil'
 rescue LoadError
 end
 
@@ -7,6 +8,8 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/fiddle/test_handle.rb#L8
   class TestHandle < TestCase
     include Fiddle
 
+    include Test::Unit::Assertions
+
     def test_to_i
       handle = Fiddle::Handle.new(LIBC_SO)
       assert_kind_of Integer, handle.to_i
@@ -185,5 +188,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/fiddle/test_handle.rb#L188
       Socket.gethostbyname("localhost")
       Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
     end if /freebsd/=~ RUBY_PLATFORM
+
+    def test_no_memory_leak
+      assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Handle.allocate}; GC.start', rss: true)
+    end
   end
 end if defined?(Fiddle)
Index: ruby_2_0_0/test/dl/test_cptr.rb
===================================================================
--- ruby_2_0_0/test/dl/test_cptr.rb	(revision 46507)
+++ ruby_2_0_0/test/dl/test_cptr.rb	(revision 46508)
@@ -219,4 +219,8 @@ module DL https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/dl/test_cptr.rb#L219
       assert_raise(DLError) {nullpo[0] = 1}
     end
   end
+
+  def test_no_memory_leak
+    assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::CPtr.allocate}', rss: true)
+  end
 end
Index: ruby_2_0_0/test/dl/test_handle.rb
===================================================================
--- ruby_2_0_0/test/dl/test_handle.rb	(revision 46507)
+++ ruby_2_0_0/test/dl/test_handle.rb	(revision 46508)
@@ -184,4 +184,8 @@ module DL https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/dl/test_handle.rb#L184
       DL.dlopen("/lib/libc.so.7").sym('strcpy')
     end if /freebsd/=~ RUBY_PLATFORM
   end
+
+  def test_no_memory_leak
+    assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::Handle.allocate}; GC.start', rss: true)
+  end
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45291,45299,45314,45325


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

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