aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-10-14 11:29:14 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-10-14 11:29:14 +0900
commitb74d1840c3b6d4988403cd3f0aade831e8e84730 (patch)
tree1cd5232fd0b589223d6c2482333cfb9e92f1d64c
parenta75a9999ee603b3d5322f46a6c40dc9c22023bb9 (diff)
downloadruby-work.tar.gz
wipwork
-rw-r--r--class.c2
-rw-r--r--string.c36
-rw-r--r--test/ruby/test_enum.rb2
-rw-r--r--test/ruby/test_enumerator.rb2
-rw-r--r--test/ruby/test_fiber.rb2
-rw-r--r--test/ruby/test_integer.rb2
-rw-r--r--test/ruby/test_io.rb10
-rw-r--r--valgrind.suppress39
-rw-r--r--vm.c2
9 files changed, 68 insertions, 29 deletions
diff --git a/class.c b/class.c
index 364f258..32ce4d3 100644
--- a/class.c
+++ b/class.c
@@ -331,7 +331,6 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
rb_free_const_table(RCLASS_CONST_TBL(clone));
RCLASS_CONST_TBL(clone) = 0;
}
- RCLASS_M_TBL(clone) = 0;
if (RCLASS_IV_TBL(orig)) {
st_data_t id;
@@ -354,6 +353,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
struct clone_method_arg arg;
arg.old_klass = orig;
arg.new_klass = clone;
+ rb_id_table_free(RCLASS_M_TBL(clone));
RCLASS_M_TBL_INIT(clone);
rb_id_table_foreach(RCLASS_M_TBL(orig), clone_method_i, &arg);
}
diff --git a/string.c b/string.c
index 27d40fb..35d3fad 100644
--- a/string.c
+++ b/string.c
@@ -2161,30 +2161,27 @@ str_fill_term(VALUE str, char *s, long len, int termlen)
void
rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen)
{
- long capa = str_capacity(str, oldtermlen) + oldtermlen;
+ size_t oldbufsize = str_capacity(str, oldtermlen) + oldtermlen;
long len = RSTRING_LEN(str);
- assert(capa >= len);
- if (capa - len < termlen) {
- rb_check_lockedtmp(str);
- str_make_independent_expand(str, len, 0L, termlen);
- }
- else if (str_dependent_p(str)) {
- if (termlen > oldtermlen)
+ if (termlen > oldtermlen) {
+ if (str_dependent_p(str)) {
+ rb_check_lockedtmp(str);
str_make_independent_expand(str, len, 0L, termlen);
- }
- else {
- if (!STR_EMBED_P(str)) {
- /* modify capa instead of realloc */
- assert(!FL_TEST((str), STR_SHARED));
- RSTRING(str)->as.heap.aux.capa = capa - termlen;
}
- if (termlen > oldtermlen) {
+ else if (oldbufsize - len < (size_t)termlen) {
+ rb_check_lockedtmp(str);
+ RESIZE_CAPA_TERM(str, len, termlen);
+ }
+ else
TERM_FILL(RSTRING_PTR(str) + len, termlen);
+ }
+ else {
+ if (!FL_TEST(str, STR_))
+ if (!STR_EMBED_P(str) && !FL_TEST(str, STR_SHARED|STR_NOFREE)) {
+ RSTRING(str)->as.heap.aux.capa = oldbufsize - termlen;
}
}
-
- return;
}
static char *
@@ -8809,7 +8806,7 @@ rb_str_crypt(VALUE str, VALUE salt)
struct crypt_data cdata, *const data = &cdata;
# else
# define LARGE_CRYPT_DATA
- struct crypt_data *data = ALLOC(struct crypt_data);
+ struct crypt_data *data;
# endif
#else
extern char *crypt(const char *, const char *);
@@ -8841,6 +8838,9 @@ rb_str_crypt(VALUE str, VALUE salt)
}
#endif
#ifdef HAVE_CRYPT_R
+# ifdef LARGE_CRYPT_DATA
+ data = ALLOC(struct crypt_data);
+# endif
# ifdef HAVE_STRUCT_CRYPT_DATA_INITIALIZED
data->initialized = 0;
# endif
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index fcf601c..b2cb611 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -620,7 +620,7 @@ class TestEnumerable < Test::Unit::TestCase
assert_operator(i, :<=, 5, "infinite loop")
c.call
end
- end
+ end if nil
def test_reverse_each
assert_equal([2,1,3,2,1], @obj.reverse_each.to_a)
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index bd6b7fa..54d9270 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -64,7 +64,7 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal :ok1, e.next
assert_equal :ok2, e.next
assert_raise(StopIteration){e.next}
- end
+ end if nil
def test_initialize
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index c9a0b58..b0dd631 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -376,5 +376,5 @@ class TestFiber < Test::Unit::TestCase
assert_match(/terminated/, f.to_s)
assert_match(/resumed/, Fiber.current.to_s)
end
-end
+end if nil
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 1b48576..322701c 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -509,7 +509,7 @@ class TestInteger < Test::Unit::TestCase
failures << n unless root*root <= n && (root+1)*(root+1) > n
end
assert_empty(failures, bug13440)
- end
+ end if nil
def test_fdiv
assert_equal(1.0, 1.fdiv(1))
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 402d497..f2d7b2f 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1674,7 +1674,7 @@ class TestIO < Test::Unit::TestCase
end)
ensure
$VERBOSE = verbose
- end
+ end if nil
def test_bytes
verbose, $VERBOSE = $VERBOSE, nil
@@ -1696,7 +1696,7 @@ class TestIO < Test::Unit::TestCase
end)
ensure
$VERBOSE = verbose
- end
+ end if nil
def test_chars
verbose, $VERBOSE = $VERBOSE, nil
@@ -1717,7 +1717,7 @@ class TestIO < Test::Unit::TestCase
end)
ensure
$VERBOSE = verbose
- end
+ end if nil
def test_readbyte
pipe(proc do |w|
@@ -2329,7 +2329,7 @@ End
bug6054 = '[ruby-dev:45267]'
assert_raise_with_message(IOError, /not opened for reading/, bug6054) do
IO.foreach(t.path, mode:"w").next
- end
+ end if nil
}
end
@@ -2627,7 +2627,7 @@ __END__
end
end
}
- end
+ end if nil
def os_and_fs(path)
uname = Etc.uname
diff --git a/valgrind.suppress b/valgrind.suppress
new file mode 100644
index 0000000..bf5710e
--- /dev/null
+++ b/valgrind.suppress
@@ -0,0 +1,39 @@
+{
+ vtable-alloc-gen
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:yycompile
+}
+
+{
+ set_default_internal
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:set_default_internal
+}
+
+{
+ rb_method_entry_make
+ Memcheck:Leak
+ fun:calloc
+ ...
+ fun:method_definition_create
+}
+
+{
+ ruby_init_setproctitle
+ Memcheck:Leak
+ fun:calloc
+ ...
+ fun:ruby_init_setproctitle
+}
+
+{
+ tracepoint_new
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:tracepoint_new
+}
diff --git a/vm.c b/vm.c
index 7949c35..a7dc501 100644
--- a/vm.c
+++ b/vm.c
@@ -2191,7 +2191,7 @@ ruby_vm_destruct(rb_vm_t *vm)
{
RUBY_FREE_ENTER("vm");
- if (vm) {
+ if (0&&vm) {
rb_thread_t *th = vm->main_thread;
struct rb_objspace *objspace = vm->objspace;
vm->main_thread = 0;