summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 10:09:30 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 10:09:30 (GMT)
commit48324dd4db07f505fc7f645b3102483891abe47f (patch)
tree82bef9505e19c1b5642b1f3d237499d495917885 /io.c
parent956d35e2d00e331ad2bbf601db5f05bbf7097be8 (diff)
io.c (io_write_nonblock): add RB_GC_GUARD, io_fflush may switch threads
Since io_fflush may block on mutex or rb_io_wait_readable and switch threads, we need to ensure the `str' VALUE returned by `rb_obj_as_string` is visible to GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/io.c b/io.c
index 1a22d34..442bf52 100644
--- a/io.c
+++ b/io.c
@@ -3001,6 +3001,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex)
rb_io_set_nonblock(fptr);
n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
+ RB_GC_GUARD(str);
if (n < 0) {
int e = errno;