[macruby-changes] [3053] MacRuby/trunk/vm.cpp

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 25 13:45:33 PST 2009


Revision: 3053
          http://trac.macosforge.org/projects/ruby/changeset/3053
Author:   lsansonetti at apple.com
Date:     2009-11-25 13:45:31 -0800 (Wed, 25 Nov 2009)
Log Message:
-----------
#throw must clear the current VM exception before unwinding the stack

Modified Paths:
--------------
    MacRuby/trunk/vm.cpp

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-11-25 11:46:28 UTC (rev 3052)
+++ MacRuby/trunk/vm.cpp	2009-11-25 21:45:31 UTC (rev 3053)
@@ -3915,7 +3915,6 @@
 RoxorVM::ruby_throw(VALUE tag, VALUE value)
 {
     std::map<VALUE, int*>::iterator iter = catch_nesting.find(tag);
-
     if (iter == catch_nesting.end()) {
         VALUE desc = rb_inspect(tag);
         rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
@@ -3923,12 +3922,18 @@
 
     GC_RETAIN(value);
 
+    // We must pop the current VM exception in case we are in a rescue handler,
+    // since we are going to unwind the stack.
+    if (current_exception() != Qnil) {
+	pop_current_exception();
+    }
+
     RoxorCatchThrowException *exc = new RoxorCatchThrowException;
     exc->throw_symbol = tag;
     exc->throw_value = value;
     // There is no way - yet - to retrieve the exception from the ABI
     // So instead, we store the exception in the VM
-    GET_VM()->set_throw_exc(exc);
+    set_throw_exc(exc);
     throw exc;
 
     return Qnil; // Never reached;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091125/be28a1ac/attachment.html>


More information about the macruby-changes mailing list