Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reenable Ruby finalizers

With the additional guard for Data objects and native memory, this can't
cause crashes anymore now.
  • Loading branch information...
commit 035977918a044b61bd5f4cd4a76e882a25b8ec81 1 parent fad3d9d
@dbussink dbussink authored
Showing with 22 additions and 40 deletions.
  1. +11 −14 vm/finalizer.cpp
  2. +11 −26 vm/objectmemory.cpp
View
25 vm/finalizer.cpp
@@ -140,20 +140,17 @@ namespace rubinius {
* TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
*/
- // CallFrame* call_frame = 0;
-
- // // Rubinius specific code. If the finalizer is cTrue, then
- // // send the object the finalize message
- // if(fi->ruby_finalizer == cTrue) {
- // fi->object->send(state, call_frame, state->symbol("__finalize__"));
- // } else {
- // Array* ary = Array::create(state, 1);
- // ary->set(state, 0, fi->object->id(state));
-
- // OnStack<1> os(state, ary);
-
- // fi->ruby_finalizer->send(state, call_frame, G(sym_call), ary);
- // }
+ CallFrame* call_frame = 0;
+
+ // Rubinius specific code. If the finalizer is cTrue, then
+ // send the object the finalize message
+ if(fi->ruby_finalizer == cTrue) {
+ fi->object->send(state, call_frame, state->symbol("__finalize__"));
+ } else {
+ Array* ary = Array::create(state, 1);
+ ary->set(state, 0, fi->object->id(state));
+ fi->ruby_finalizer->send(state, call_frame, G(sym_call), ary);
+ }
}
if(fi->finalizer) {
View
37 vm/objectmemory.cpp
@@ -985,34 +985,19 @@ namespace rubinius {
// Only finalize things that haven't been finalized.
if(fi.status != FinalizeObject::eFinalized) {
+ if(fi.ruby_finalizer) {
+ // Rubinius specific code. If the finalizer is cTrue, then
+ // send the object the finalize message
+ if(fi.ruby_finalizer == cTrue) {
+ fi.object->send(state, 0, state->symbol("__finalize__"));
+ } else {
+ Array* ary = Array::create(state, 1);
+ ary->set(state, 0, fi.object->id(state));
+ fi.ruby_finalizer->send(state, 0, G(sym_call), ary);
+ }
+ }
if(fi.finalizer) {
(*fi.finalizer)(state, fi.object);
- } else if(fi.ruby_finalizer) {
- /*
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- * TODO
- * TODO Temporarily disabling running Ruby finalizers until issues
- * TODO can be resolved. Yes, this will cause memory leaks. Memory
- * TODO leaks are better than segfaults.
- * TODO
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- */
-
- // // Rubinius specific code. If the finalizer is cTrue, then
- // // send the object the finalize message
- // if(fi.ruby_finalizer == cTrue) {
- // fi.object->send(state, 0, state->symbol("__finalize__"));
- // } else {
- // Array* ary = Array::create(state, 1);
- // ary->set(state, 0, fi.object->id(state));
-
- // OnStack<1> os(state, ary);
-
- // fi.ruby_finalizer->send(state, 0, G(sym_call), ary);
- // }
- } else {
- std::cerr << "During shutdown, unsupported object to be finalized: "
- << fi.object->to_s(state)->c_str(state) << std::endl;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.