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

ruby-changes:31248

From: ko1 <ko1@a...>
Date: Thu, 17 Oct 2013 14:07:26 +0900 (JST)
Subject: [ruby-changes:31248] ko1:r43327 (trunk): * ext/objspace/object_tracing.c (newobj_i): fix memory leak.

ko1	2013-10-17 14:07:21 +0900 (Thu, 17 Oct 2013)

  New Revision: 43327

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

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/objspace/object_tracing.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43326)
+++ ChangeLog	(revision 43327)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Oct 17 14:06:39 2013  Koichi Sasada  <ko1@a...>
+
+	* 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@f...>
 
 	* lib/tsort.rb (TSort.each_strongly_connected_component_from):
Index: ext/objspace/object_tracing.c
===================================================================
--- ext/objspace/object_tracing.c	(revision 43326)
+++ ext/objspace/object_tracing.c	(revision 43327)
@@ -98,8 +98,13 @@ newobj_i(VALUE tpval, void *data) https://github.com/ruby/ruby/blob/trunk/ext/objspace/object_tracing.c#L98
     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);
     }

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

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