From c4cc4d31e618a97ec4d5655a8e543514c96bcecc Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 20 Feb 2011 07:26:48 +0000 Subject: [PATCH] * thread.c (exec_recursive): prevent temporary objects from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++- thread.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ca3bd3609..05051696ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ -Sun Feb 20 16:23:52 2011 Nobuyoshi Nakada +Sun Feb 20 16:26:45 2011 Nobuyoshi Nakada + + * thread.c (exec_recursive): prevent temporary objects from GC. * prevent temporary objects from GC, and should not use RSTRING_PTR() for function calls since it evaluates the argument diff --git a/thread.c b/thread.c index 927dbc4131..54664a5503 100644 --- a/thread.c +++ b/thread.c @@ -3701,10 +3701,14 @@ exec_recursive_i(VALUE tag, struct exec_recursive_params *p) static VALUE exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer) { + VALUE result = Qundef; struct exec_recursive_params p; int outermost; p.list = recursive_list_access(); p.objid = rb_obj_id(obj); + p.obj = obj; + p.pairid = pairid; + p.arg = arg; outermost = outer && !recursive_check(p.list, ID2SYM(recursive_key), 0); if (recursive_check(p.list, p.objid, pairid)) { @@ -3714,11 +3718,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE return (*func)(obj, arg, TRUE); } else { - VALUE result = Qundef; p.func = func; - p.obj = obj; - p.pairid = pairid; - p.arg = arg; if (outermost) { recursive_push(p.list, ID2SYM(recursive_key), 0); @@ -3731,8 +3731,9 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE else { result = exec_recursive_i(0, &p); } - return result; } + *(volatile struct exec_recursive_params *)&p; + return result; } /*