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

ruby-changes:31692

From: ko1 <ko1@a...>
Date: Fri, 22 Nov 2013 10:38:15 +0900 (JST)
Subject: [ruby-changes:31692] ko1:r43771 (trunk): * vm.c (ruby_vm_destruct): do not use ruby_xfree() after freeing

ko1	2013-11-22 10:38:08 +0900 (Fri, 22 Nov 2013)

  New Revision: 43771

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

  Log:
    * vm.c (ruby_vm_destruct): do not use ruby_xfree() after freeing
      objspace.
    * gc.c (ruby_mimfree): added. It is similar to ruby_mimmalloc().
    * internal.h: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/internal.h
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43770)
+++ ChangeLog	(revision 43771)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov 22 10:35:57 2013  Koichi Sasada  <ko1@a...>
+
+	* vm.c (ruby_vm_destruct): do not use ruby_xfree() after freeing
+	  objspace.
+
+	* gc.c (ruby_mimfree): added. It is similar to ruby_mimmalloc().
+
+	* internal.h: ditto.
+
 Fri Nov 22 09:42:35 2013  Zachary Scott  <e@z...>
 
 	* test/digest/test_digest.rb: Reverse order of assert_equal
Index: gc.c
===================================================================
--- gc.c	(revision 43770)
+++ gc.c	(revision 43771)
@@ -5715,6 +5715,16 @@ ruby_mimmalloc(size_t size) https://github.com/ruby/ruby/blob/trunk/gc.c#L5715
     return mem;
 }
 
+void
+ruby_mimfree(void *ptr)
+{
+    size_t *mem = (size_t *)ptr;
+#if CALC_EXACT_MALLOC_SIZE
+    mem = mem - 1;
+#endif
+    free(mem);
+}
+
 #if CALC_EXACT_MALLOC_SIZE
 /*
  *  call-seq:
Index: internal.h
===================================================================
--- internal.h	(revision 43770)
+++ internal.h	(revision 43771)
@@ -428,6 +428,7 @@ NORETURN(void rb_syserr_fail_path_in(con https://github.com/ruby/ruby/blob/trunk/internal.h#L428
 /* gc.c */
 void Init_heap(void);
 void *ruby_mimmalloc(size_t size);
+void ruby_mimfree(void *ptr);
 void rb_objspace_set_event_hook(const rb_event_flag_t event);
 void rb_gc_writebarrier_remember_promoted(VALUE obj);
 
Index: vm.c
===================================================================
--- vm.c	(revision 43770)
+++ vm.c	(revision 43771)
@@ -1654,14 +1654,15 @@ ruby_vm_destruct(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/vm.c#L1654
 	    st_free_table(vm->living_threads);
 	    vm->living_threads = 0;
 	}
+	ruby_vm_run_at_exit_hooks(vm);
+	rb_vm_gvl_destroy(vm);
 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
 	if (objspace) {
 	    rb_objspace_free(objspace);
 	}
 #endif
-	ruby_vm_run_at_exit_hooks(vm);
-	rb_vm_gvl_destroy(vm);
-	ruby_xfree(vm);
+	/* after freeing objspace, you *can't* use ruby_xfree() */
+	ruby_mimfree(vm);
 	ruby_current_vm = 0;
     }
     RUBY_FREE_LEAVE("vm");

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

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