[#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:60404] is RB_GC_GUARD needed in rb_io_syswrite?
From:
Eric Wong <normalperson@...>
Date:
2014-02-01 09:19:18 UTC
List:
ruby-core #60404
I haven't gotten it to crash as-is, but it seems like we need to
prevent the compiler from optimizing str away while rb_write_internal
is sleeping.
--- a/io.c
+++ b/io.c
@@ -4666,38 +4666,39 @@ static VALUE
rb_io_syswrite(VALUE io, VALUE str)
{
rb_io_t *fptr;
long n;
if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
io = GetWriteIO(io);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
str = rb_str_new_frozen(str);
if (fptr->wbuf.len) {
rb_warn("syswrite for buffered IO");
}
n = rb_write_internal(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
+ RB_GC_GUARD(str);
if (n == -1) rb_sys_fail_path(fptr->pathv);
return LONG2FIX(n);
}