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

ruby-changes:38253

From: nobu <ko1@a...>
Date: Fri, 17 Apr 2015 11:59:01 +0900 (JST)
Subject: [ruby-changes:38253] nobu:r50334 (trunk): string.c: clear NOFREE flag at embedding

nobu	2015-04-17 11:58:37 +0900 (Fri, 17 Apr 2015)

  New Revision: 50334

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

  Log:
    string.c: clear NOFREE flag at embedding
    
    * string.c (STR_SET_EMBED): clear NOFREE flag at embedding as
      embedded strings no longer refer static strings.
      [ruby-core:68436] [Bug #10942]

  Added files:
    trunk/test/-ext-/string/test_nofree.rb
  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50333)
+++ ChangeLog	(revision 50334)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 17 11:58:34 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (STR_SET_EMBED): clear NOFREE flag at embedding as
+	  embedded strings no longer refer static strings.
+	  [ruby-core:68436] [Bug #10942]
+
 Thu Apr 16 05:15:50 2015  Eric Wong  <e@8...>
 
 	* NEWS: note IO#wait_readable change in r50263
Index: string.c
===================================================================
--- string.c	(revision 50333)
+++ string.c	(revision 50334)
@@ -74,7 +74,7 @@ VALUE rb_cSymbol; https://github.com/ruby/ruby/blob/trunk/string.c#L74
     FL_SET((str), STR_NOEMBED);\
     STR_SET_EMBED_LEN((str), 0);\
 } while (0)
-#define STR_SET_EMBED(str) FL_UNSET((str), STR_NOEMBED)
+#define STR_SET_EMBED(str) FL_UNSET((str), (STR_NOEMBED|STR_NOFREE))
 #define STR_SET_EMBED_LEN(str, n) do { \
     long tmp_n = (n);\
     RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
Index: test/-ext-/string/test_nofree.rb
===================================================================
--- test/-ext-/string/test_nofree.rb	(revision 0)
+++ test/-ext-/string/test_nofree.rb	(revision 50334)
@@ -0,0 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_nofree.rb#L1
+require 'test/unit'
+
+class Test_StringNoFree < Test::Unit::TestCase
+  def test_no_memory_leak
+    bug10942 = '[ruby-core:68436] [Bug #10942] no leak on nofree string'
+    assert_no_memory_leak(%w(-r-test-/string/string), '',
+                          '1000000.times {Bug::String.nofree << "a" * 100}',
+                          bug10942, rss: true)
+  end
+end

Property changes on: test/-ext-/string/test_nofree.rb
___________________________________________________________________
Added: svn:eol-style
   + LF


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

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