[#60404] is RB_GC_GUARD needed in rb_io_syswrite? — Eric Wong <normalperson@...>
I haven't gotten it to crash as-is, but it seems like we need to
4 messages
2014/02/01
[#60682] volatile usages — Eric Wong <normalperson@...>
Hi all, I went ahead and removed some use of volatile which were once
5 messages
2014/02/13
[#60794] [RFC] rearrange+pack vtm and time_object structs — Eric Wong <normalperson@...>
Extracted from addendum on top of Feature #9362 (cache-aligned objects).
4 messages
2014/02/16
[#61139] [ruby-trunk - Feature #9577] [Open] [PATCH] benchmark/driver.rb: align columns in text output — normalperson@...
Issue #9577 has been reported by Eric Wong.
3 messages
2014/02/28
[ruby-core:60780] Re: volatile usages
From:
Eric Wong <normalperson@...>
Date:
2014-02-16 04:48:05 UTC
List:
ruby-core #60780
Eric Wong <normalperson@yhbt.net> wrote:
> array.c: volatile in rb_ary_each along with the explanation in r32201 is
> scaring me :x If that volatile is needed, then it would also be
> necessary in similar functions such as rb_ary_each_with_index and
> rb_reverse_each. Of course, those functions do not use volatile and
> seem fine after all these years.
I suspect it is because rb_ary_each is in the public C API,
so a guard becomes necessary.
--- a/array.c
+++ b/array.c
@@ -1784,16 +1784,21 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj)
*/
VALUE
-rb_ary_each(VALUE array)
+rb_ary_each(VALUE ary)
{
long i;
- volatile VALUE ary = array;
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
for (i=0; i<RARRAY_LEN(ary); i++) {
rb_yield(RARRAY_AREF(ary, i));
}
- return ary;
+
+ /*
+ * GC guard may be necessary if rb_ary_each is called like this:
+ * rb_ary_each(rb_ary_new());
+ * (ary argument is allocated inline and the return value ignored)
+ */
+ return RB_GC_GUARD(ary);
}
/*