merge revision(s) 6e7e7c1e57: [Backport #17023]

Only marked objects should be considered movable

	Ruby's GC is incremental, meaning that during the mark phase (and also
	the sweep phase) programs are allowed to run.  This means that programs
	can allocate objects before the mark or sweep phase have actually
	completed.  Those objects may not have had a chance to be marked, so we
	can't know if they are movable or not. Something that references the
	newly created object might have called the pinning function during the
	mark phase, but since the mark phase hasn't run we can't know if there
	is a "pinning" relationship.

	To be conservative, we must only allow objects that are not pinned but
	also marked to move.
This commit is contained in:
nagachika 2020-07-19 11:52:11 +09:00
parent ad15fd03e9
commit e619178e52
2 changed files with 2 additions and 2 deletions

2
gc.c
View file

@ -7569,7 +7569,7 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
return FALSE; return FALSE;
} }
} }
return !RVALUE_PINNED(obj); return RVALUE_MARKED(obj) && !RVALUE_PINNED(obj);
break; break;
default: default:

View file

@ -2,7 +2,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 1 #define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 94 #define RUBY_PATCHLEVEL 95
#define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_YEAR 2020
#define RUBY_RELEASE_MONTH 7 #define RUBY_RELEASE_MONTH 7