1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 50334,50337: [Backport #10942]

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2015-05-19 19:52:07 +00:00
parent ddf1f59df5
commit 20ef4699e5
5 changed files with 31 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Wed May 20 04:33:50 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (STR_SET_EMBED): clear NOFREE flag at embedding as
embedded strings no longer refer static strings.
[ruby-core:68436] [Bug #10942]
Wed May 20 03:46:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (need_normalization): use getattrlist() if fgetattrlist()

View file

@ -0,0 +1,13 @@
#include "ruby.h"
VALUE
bug_str_nofree(VALUE self)
{
return rb_str_new_cstr("abcdef");
}
void
Init_nofree(VALUE klass)
{
rb_define_singleton_method(klass, "nofree", bug_str_nofree, 0);
}

View file

@ -60,7 +60,7 @@ VALUE rb_cSymbol;
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;\

View file

@ -0,0 +1,10 @@
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, limit: 2.0)
end
end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.3"
#define RUBY_RELEASE_DATE "2015-05-20"
#define RUBY_PATCHLEVEL 109
#define RUBY_PATCHLEVEL 110
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 5