ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: SASADA Koichi <ko1@atdot.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:61366] Re: [ruby-trunk - Bug #9609] [Open] [PATCH] vm_eval.c: fix misplaced RB_GC_GUARDs
Date: Fri, 07 Mar 2014 20:03:26 +0900	[thread overview]
Message-ID: <5319A77E.8050401@atdot.net> (raw)
In-Reply-To: <20140307103815.GA10957@dcvr.yhbt.net>

(2014/03/07 19:38), Eric Wong wrote:
> Thanks (r45283).   Btw, I noticed rb_apply uses RARRAY_PTR, too,
> but also with OBJ_FREEZE.
> 
> Should we ignore WB unprotect for frozen objects?

No relation between frozen and wb unprotected flag. We can use
RARRAY_CONST_PTR() for this case. I'll commit it with other patches.



Index: enum.c
===================================================================
--- enum.c	(revision 45283)
+++ enum.c	(working copy)
@@ -1163,7 +1163,7 @@ static void
 nmin_filter(struct nmin_data *data)
 {
     long n;
-    VALUE *beg;
+    const VALUE *beg;
     int eltsize;
     long numelts;

@@ -1175,7 +1175,7 @@ nmin_filter(struct nmin_data *data)
 	return;

     n = data->n;
-    beg = RARRAY_PTR(data->buf);
+    beg = RARRAY_CONST_PTR(data->buf);
     eltsize = data->by ? 2 : 1;
     numelts = data->curlen;

Index: enumerator.c
===================================================================
--- enumerator.c	(revision 45283)
+++ enumerator.c	(working copy)
@@ -422,13 +422,13 @@ static VALUE
 enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
 {
     int argc = 0;
-    VALUE *argv = 0;
+    const VALUE *argv = 0;
     const struct enumerator *e = enumerator_ptr(obj);
     ID meth = e->meth;

     if (e->args) {
 	argc = RARRAY_LENINT(e->args);
-	argv = RARRAY_PTR(e->args);
+	argv = RARRAY_CONST_PTR(e->args);
     }
     return rb_block_call(e->obj, meth, argc, argv, func, arg);
 }
Index: internal.h
===================================================================
--- internal.h	(revision 45283)
+++ internal.h	(working copy)
@@ -963,9 +963,9 @@ VALUE rb_int_positive_pow(long x, unsign
 /* process.c */
 int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg,
size_t errmsg_buflen);
 rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*,
char *, size_t), void *charg, VALUE fds, char *errmsg, size_t
errmsg_buflen);
-VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
+VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
 struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous.
needs GC guard. */
-VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE
execarg_obj);
+VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell,
VALUE execarg_obj);
 int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
 void rb_execarg_fixup(VALUE execarg_obj);
 int rb_execarg_run_options(const struct rb_execarg *e, struct
rb_execarg *s, char* errmsg, size_t errmsg_buflen);
Index: io.c
===================================================================
--- io.c	(revision 45283)
+++ io.c	(working copy)
@@ -6227,7 +6227,7 @@ rb_io_s_popen(int argc, VALUE *argv, VAL
 #endif
 	tmp = rb_ary_dup(tmp);
 	RBASIC_CLEAR_CLASS(tmp);
-	execarg_obj = rb_execarg_new((int)len, RARRAY_PTR(tmp), FALSE);
+	execarg_obj = rb_execarg_new((int)len, RARRAY_CONST_PTR(tmp), FALSE);
 	rb_ary_clear(tmp);
     }
     else {
Index: numeric.c
===================================================================
--- numeric.c	(revision 45283)
+++ numeric.c	(working copy)
@@ -1887,7 +1887,7 @@ num_step_size(VALUE from, VALUE args, VA
     VALUE to, step, hash;
     int desc;
     int argc = args ? RARRAY_LENINT(args) : 0;
-    VALUE *argv = args ? RARRAY_PTR(args) : 0;
+    const VALUE *argv = args ? RARRAY_CONST_PTR(args) : 0;

     NUM_STEP_SCAN_ARGS(argc, argv, to, step, hash, desc);

Index: process.c
===================================================================
--- process.c	(revision 45283)
+++ process.c	(working copy)
@@ -2167,7 +2167,7 @@ rb_exec_fillarg(VALUE prog, int argc, VA
 }

 VALUE
-rb_execarg_new(int argc, VALUE *argv, int accept_shell)
+rb_execarg_new(int argc, const VALUE *argv, int accept_shell)
 {
     VALUE execarg_obj;
     struct rb_execarg *eargp;
@@ -2186,7 +2186,7 @@ rb_execarg_get(VALUE execarg_obj)
 }

 VALUE
-rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj)
+rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE
execarg_obj)
 {
     struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
     VALUE prog, ret;
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 45283)
+++ vm_eval.c	(working copy)
@@ -751,7 +751,7 @@ rb_apply(VALUE recv, ID mid, VALUE args)
 	args = rb_ary_subseq(args, 0, argc);
 	RBASIC_CLEAR_CLASS(args);
 	OBJ_FREEZE(args);
-	ret = rb_call(recv, mid, argc, RARRAY_PTR(args), CALL_FCALL);
+	ret = rb_call(recv, mid, argc, RARRAY_CONST_PTR(args), CALL_FCALL);
 	RB_GC_GUARD(args);
 	return ret;
     }
@@ -1482,7 +1482,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int le
 	rb_set_safe_level_force(level);
 	if ((state = EXEC_TAG()) == 0) {
 	    val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LENINT(arg),
-			      RARRAY_PTR(arg));
+			      RARRAY_CONST_PTR(arg));
 	}
 	POP_TAG();




-- 
// SASADA Koichi at atdot dot net

  reply	other threads:[~2014-03-07 11:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-9609.20140307100943@ruby-lang.org>
2014-03-07 10:09 ` [ruby-core:61359] [ruby-trunk - Bug #9609] [Open] [PATCH] vm_eval.c: fix misplaced RB_GC_GUARDs normalperson
2014-03-07 10:21   ` [ruby-core:61360] " SASADA Koichi
2014-03-07 10:38     ` [ruby-core:61362] " Eric Wong
2014-03-07 11:03       ` SASADA Koichi [this message]
2014-03-07 11:06         ` [ruby-core:61367] " SASADA Koichi
2014-03-07 10:22 ` [ruby-core:61361] [ruby-trunk - Bug #9609] " ko1
2014-03-07 10:41 ` [ruby-core:61363] " normalperson
2014-03-07 11:10 ` [ruby-core:61368] " ko1
2014-03-07 11:10 ` [ruby-core:61369] " ko1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5319A77E.8050401@atdot.net \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).