diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-17 05:07:21 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-17 05:07:21 +0000 |
commit | 3f2828078273ec2b92afe27d3b081049bca2bcd2 (patch) | |
tree | 452db365d2dc6fdf0a2e2769b270e01fbc69f874 | |
parent | ed6231195b8c516a32019e1967366af7793e8313 (diff) | |
download | ruby-3f2828078273ec2b92afe27d3b081049bca2bcd2.tar.gz |
* ext/objspace/object_tracing.c (newobj_i): fix memory leak.
There is possibility to remain info due to missing FREEOBJ event.
FREEOBJ events are skipped while suppress_tracing state, for example,
during trace events are invoking.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ext/objspace/object_tracing.c | 9 |
2 files changed, 14 insertions, 2 deletions
@@ -1,3 +1,10 @@ +Thu Oct 17 14:06:39 2013 Koichi Sasada <ko1@atdot.net> + + * ext/objspace/object_tracing.c (newobj_i): fix memory leak. + There is possibility to remain info due to missing FREEOBJ event. + FREEOBJ events are skipped while suppress_tracing state, for example, + during trace events are invoking. + Thu Oct 17 12:30:16 2013 Tanaka Akira <akr@fsij.org> * lib/tsort.rb (TSort.each_strongly_connected_component_from): diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c index 9de9724400..1770a8ea39 100644 --- a/ext/objspace/object_tracing.c +++ b/ext/objspace/object_tracing.c @@ -98,8 +98,13 @@ newobj_i(VALUE tpval, void *data) VALUE class_path = RTEST(klass) ? rb_class_path(klass) : Qnil; const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0; - if (arg->keep_remains && st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) { - if (0 /* workaround */) if (info->living) rb_bug("newobj_i: reuse living object: %p", (void *)obj); + if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) { + if (arg->keep_remains) { + if (info->living) { + /* do nothing. there is possibility to keep living if FREEOBJ events while suppressing tracing */ + } + } + /* reuse info */ delete_unique_str(arg->str_table, info->path); delete_unique_str(arg->str_table, info->class_path); } |