Permalink
Browse files

Guard cases where we might GC with OnStack

In these cases it was possible that a GC was triggered when dispatching
a method into Ruby land. We didn't propery mark the object as OnStack in
that case which could cause an on object to be seen.

Fixes #1770
  • Loading branch information...
dbussink committed Jun 7, 2012
1 parent 4f53f0c commit 493ee4cb2cfcc0b7d81d95edcc8ec470fc500acf
Showing with 7 additions and 0 deletions.
  1. +2 −0 vm/builtin/nativemethod.cpp
  2. +1 −0 vm/instructions.cpp
  3. +1 −0 vm/instructions.def
  4. +3 −0 vm/llvm/jit_util.cpp
@@ -11,6 +11,7 @@
#include "call_frame.hpp"
#include "objectmemory.hpp"
#include "configuration.hpp"
+#include "on_stack.hpp"
#include "builtin/array.hpp"
#include "builtin/exception.hpp"
@@ -688,6 +689,7 @@ namespace rubinius {
ep.pop(env);
LEAVE_CAPI(state);
+ OnStack<1> os(state, ret);
// Handle any signals that occurred while the native method
// was running.
View
@@ -28,6 +28,7 @@
#include "dispatch.hpp"
#include "instructions.hpp"
#include "configuration.hpp"
+#include "on_stack.hpp"
#include "helpers.hpp"
#include "inline_cache.hpp"
View
@@ -1290,6 +1290,7 @@ instruction cast_for_splat_block_arg() [ -- arguments ]
* object itself is wrapped in an Array and passed to the block.
*/
if(CBOOL(obj->respond_to(state, state->symbol("to_ary"), cFalse))) {
+ OnStack<1> os(state, obj);
Object* ignored = obj->send(state, call_frame, state->symbol("to_ary"));
if(!ignored->nil_p() && !kind_of<Array>(ignored)) {
Exception::type_error(state, "to_ary must return an Array", call_frame);
View
@@ -6,6 +6,7 @@
#include "vm.hpp"
#include "objectmemory.hpp"
#include "call_frame.hpp"
+#include "on_stack.hpp"
#include "builtin/object.hpp"
#include "builtin/symbol.hpp"
@@ -407,6 +408,7 @@ extern "C" {
* object itself is wrapped in an Array and passed to the block.
*/
if(CBOOL(obj->respond_to(state, state->symbol("to_ary"), cFalse))) {
+ OnStack<1> os(state, obj);
Object* ignored = obj->send(state, call_frame, state->symbol("to_ary"));
if(!ignored->nil_p() && !kind_of<Array>(ignored)) {
Exception::type_error(state, "to_ary must return an Array", call_frame);
@@ -478,6 +480,7 @@ extern "C" {
* object itself is wrapped in an Array and passed to the block.
*/
if(CBOOL(obj->respond_to(state, state->symbol("to_ary"), cFalse))) {
+ OnStack<1> os(state, obj);
Object* ignored = obj->send(state, call_frame, state->symbol("to_ary"));
if(!kind_of<Array>(ignored)) {
Exception::type_error(state, "to_ary must return an Array", call_frame);

0 comments on commit 493ee4c

Please sign in to comment.