mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
merge revision(s) c42261059d
: [Backport #19901]
[Bug #19901] fix leak in module clone Co-authored-by: Peter Zhu <peter@peterzhu.ca> --- class.c | 1 + test/ruby/test_module.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+)
This commit is contained in:
parent
97b7070ebd
commit
a191cf5617
3 changed files with 14 additions and 1 deletions
1
class.c
1
class.c
|
@ -445,6 +445,7 @@ copy_tables(VALUE clone, VALUE orig)
|
||||||
rb_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
|
rb_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
|
||||||
RCLASS_CVC_TBL(clone) = rb_cvc_tbl_dup;
|
RCLASS_CVC_TBL(clone) = rb_cvc_tbl_dup;
|
||||||
}
|
}
|
||||||
|
rb_id_table_free(RCLASS_M_TBL(clone));
|
||||||
RCLASS_M_TBL(clone) = 0;
|
RCLASS_M_TBL(clone) = 0;
|
||||||
if (!RB_TYPE_P(clone, T_ICLASS)) {
|
if (!RB_TYPE_P(clone, T_ICLASS)) {
|
||||||
st_data_t id;
|
st_data_t id;
|
||||||
|
|
|
@ -3318,6 +3318,18 @@ class TestModule < Test::Unit::TestCase
|
||||||
CODE
|
CODE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_module_clone_memory_leak
|
||||||
|
# [Bug #19901]
|
||||||
|
assert_no_memory_leak([], <<~PREP, <<~CODE, rss: true)
|
||||||
|
code = proc do
|
||||||
|
Module.new.clone
|
||||||
|
end
|
||||||
|
1_000.times(&code)
|
||||||
|
PREP
|
||||||
|
1_000_000.times(&code)
|
||||||
|
CODE
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_top_method_is_private(method)
|
def assert_top_method_is_private(method)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 2
|
#define RUBY_VERSION_TEENY 2
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 122
|
#define RUBY_PATCHLEVEL 123
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
#include "ruby/internal/abi.h"
|
#include "ruby/internal/abi.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue