Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 493ee4cb2cfcc0b7d81d95edcc8ec470fc500acf 1 parent 4f53f0c
@dbussink dbussink authored
View
2  vm/builtin/nativemethod.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
1  vm/instructions.cpp
@@ -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
1  vm/instructions.def
@@ -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
3  vm/llvm/jit_util.cpp
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.