ruby-changes:62964
From: Samuel <ko1@a...>
Date: Tue, 15 Sep 2020 19:53:36 +0900 (JST)
Subject: [ruby-changes:62964] a9b2a96c5c (master): Fix incorrect initialization of `rb_io_t::self`.
https://git.ruby-lang.org/ruby.git/commit/?id=a9b2a96c5c From a9b2a96c5cfa5ab36c89ffae82e28eb733e36542 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Tue, 15 Sep 2020 14:19:54 +1200 Subject: Fix incorrect initialization of `rb_io_t::self`. diff --git a/gc.c b/gc.c index 69cc2ba..cf42d32 100644 --- a/gc.c +++ b/gc.c @@ -5636,6 +5636,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L5636 case T_FILE: if (any->as.file.fptr) { + gc_mark(objspace, any->as.file.fptr->self); gc_mark(objspace, any->as.file.fptr->pathv); gc_mark(objspace, any->as.file.fptr->tied_io_for_writing); gc_mark(objspace, any->as.file.fptr->writeconv_asciicompat); @@ -8555,6 +8556,7 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L8556 case T_FILE: if (any->as.file.fptr) { + UPDATE_IF_MOVED(objspace, any->as.file.fptr->self); UPDATE_IF_MOVED(objspace, any->as.file.fptr->pathv); UPDATE_IF_MOVED(objspace, any->as.file.fptr->tied_io_for_writing); UPDATE_IF_MOVED(objspace, any->as.file.fptr->writeconv_asciicompat); diff --git a/io.c b/io.c index ed808d0..e5fac3c 100644 --- a/io.c +++ b/io.c @@ -8214,6 +8214,7 @@ prep_io(int fd, int fmode, VALUE klass, const char *path) https://github.com/ruby/ruby/blob/trunk/io.c#L8214 VALUE io = io_alloc(klass); MakeOpenFile(io, fp); + fp->self = io; fp->fd = fd; fp->mode = fmode; if (!io_check_tty(fp)) { @@ -8297,6 +8298,7 @@ static inline rb_io_t * https://github.com/ruby/ruby/blob/trunk/io.c#L8298 rb_io_fptr_new(void) { rb_io_t *fp = ALLOC(rb_io_t); + fp->self = Qnil; fp->fd = -1; fp->stdio_file = NULL; fp->mode = 0; @@ -8329,11 +8331,12 @@ rb_io_make_open_file(VALUE obj) https://github.com/ruby/ruby/blob/trunk/io.c#L8331 Check_Type(obj, T_FILE); if (RFILE(obj)->fptr) { - rb_io_close(obj); - rb_io_fptr_finalize(RFILE(obj)->fptr); - RFILE(obj)->fptr = 0; + rb_io_close(obj); + rb_io_fptr_finalize(RFILE(obj)->fptr); + RFILE(obj)->fptr = 0; } fp = rb_io_fptr_new(); + fp->self = obj; RFILE(obj)->fptr = fp; return fp; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/