summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:18:15 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-28 23:18:15 +0000
commit1c0add85ca100eb93a3455aa51a4ffe13bb72e35 (patch)
treebaf5ea99fc61d9bd1bbe556c29e91514c8965c7a
parentf0a2b08d02e9e439e8d700f49e6a348b2d3ee9e0 (diff)
merges r30922 and r30924 from trunk into ruby_1_9_2.
-- * prevent temporary objects from GC, and should not use RSTRING_PTR() for function calls since it evaluates the argument a couple of times. -- * thread.c (exec_recursive): prevent temporary objects from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--compile.c2
-rw-r--r--error.c3
-rw-r--r--thread.c11
-rw-r--r--variable.c3
-rw-r--r--version.h6
-rw-r--r--vm.c2
-rw-r--r--vm_eval.c3
-rw-r--r--vm_insnhelper.c2
9 files changed, 26 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 3fda1e8a9e..51ef23795a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Feb 20 16:26:45 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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
+ a couple of times.
+
Sun Feb 20 02:14:09 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* signal.c (sig_trap): avoid pthread_sigmask(xx, &mask, &mask) usage
diff --git a/compile.c b/compile.c
index 76dc76a161..1e8c09c929 100644
--- a/compile.c
+++ b/compile.c
@@ -5173,7 +5173,7 @@ get_exception_sym2type(VALUE sym)
if (sym == symNext) return CATCH_TYPE_NEXT;
sym_inspect = rb_inspect(sym);
rb_raise(rb_eSyntaxError, "invalid exception symbol: %s",
- RSTRING_PTR(RB_GC_GUARD(sym_inspect)));
+ StringValuePtr(sym_inspect));
return 0;
}
diff --git a/error.c b/error.c
index c519d0c4ca..459b964df0 100644
--- a/error.c
+++ b/error.c
@@ -336,7 +336,8 @@ rb_check_type(VALUE x, int t)
etype = "Symbol";
}
else if (rb_special_const_p(x)) {
- etype = RSTRING_PTR(rb_obj_as_string(x));
+ x = rb_obj_as_string(x);
+ etype = StringValuePtr(x);
}
else {
etype = rb_obj_classname(x);
diff --git a/thread.c b/thread.c
index 669c7bdd65..76f4cb6763 100644
--- a/thread.c
+++ b/thread.c
@@ -3637,10 +3637,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)) {
@@ -3650,11 +3654,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);
@@ -3667,8 +3667,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;
}
/*
diff --git a/variable.c b/variable.c
index f27b73841b..d97c7eff1a 100644
--- a/variable.c
+++ b/variable.c
@@ -310,7 +310,8 @@ rb_class_name(VALUE klass)
const char *
rb_class2name(VALUE klass)
{
- return RSTRING_PTR(rb_class_name(klass));
+ VALUE name = rb_class_name(klass);
+ return RSTRING_PTR(name);
}
const char *
diff --git a/version.h b/version.h
index 865cca0bfe..77345dc4b9 100644
--- a/version.h
+++ b/version.h
@@ -1,13 +1,13 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 204
+#define RUBY_PATCHLEVEL 205
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2011
#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 12
-#define RUBY_RELEASE_DATE "2011-05-12"
+#define RUBY_RELEASE_DAY 28
+#define RUBY_RELEASE_DATE "2011-05-28"
#include "ruby/version.h"
diff --git a/vm.c b/vm.c
index 01231f7235..f127f5be12 100644
--- a/vm.c
+++ b/vm.c
@@ -1443,7 +1443,7 @@ rb_thread_current_status(const rb_thread_t *th)
}
else if (cfp->me->def->original_id) {
str = rb_sprintf("`%s#%s' (cfunc)",
- RSTRING_PTR(rb_class_name(cfp->me->klass)),
+ rb_class2name(cfp->me->klass),
rb_id2name(cfp->me->def->original_id));
}
diff --git a/vm_eval.c b/vm_eval.c
index 0afbd285d9..521a2a5439 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1014,7 +1014,8 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char
th->base_block = 0;
if (0) { /* for debug */
- printf("%s\n", RSTRING_PTR(rb_iseq_disasm(iseqval)));
+ VALUE disasm = rb_iseq_disasm(iseqval);
+ printf("%s\n", StringValuePtr(disasm));
}
/* save new env */
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 9f2d050ec7..6b78394ca2 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1142,7 +1142,7 @@ vm_check_if_namespace(VALUE klass)
default:
str = rb_inspect(klass);
rb_raise(rb_eTypeError, "%s is not a class/module",
- RSTRING_PTR(RB_GC_GUARD(str)));
+ StringValuePtr(str));
}
}