1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 1fac99afda: [Backport #18030]

skip marking for uninitialized imemo_env.

	RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env
	objects and marking it will cause critical error. This patch
	skips marking on uninitialized imemo_env.

	See: http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210329T183003Z.fail.html.gz

	Shortest repro-code is provided by mame-san.
	---
	 gc.c                           | 16 ++++++++++------
	 test/objspace/test_objspace.rb | 13 +++++++++++++
	 2 files changed, 23 insertions(+), 6 deletions(-)
This commit is contained in:
nagachika 2021-07-18 10:58:55 +09:00
parent 3540939b95
commit ca6ebde821
3 changed files with 25 additions and 8 deletions

4
gc.c
View file

@ -6187,6 +6187,9 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
case imemo_env:
{
const rb_env_t *env = (const rb_env_t *)obj;
if (LIKELY(env->ep)) {
// just after newobj() can be NULL here.
GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
gc_mark_values(objspace, (long)env->env_size, env->env);
@ -6194,6 +6197,7 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
gc_mark(objspace, (VALUE)env->iseq);
}
}
return;
case imemo_cref:
gc_mark(objspace, RANY(obj)->as.imemo.cref.klass);

View file

@ -243,6 +243,19 @@ class TestObjSpace < Test::Unit::TestCase
GC.enable
end
def test_trace_object_allocations_gc_stress
prev = GC.stress
GC.stress = true
ObjectSpace.trace_object_allocations{
proc{}
}
assert true # success
ensure
GC.stress = prev
end
def test_dump_flags
info = ObjectSpace.dump("foo".freeze)
assert_match(/"wb_protected":true, "old":true/, info)

View file

@ -12,11 +12,11 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 108
#define RUBY_PATCHLEVEL 109
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 7
#define RUBY_RELEASE_DAY 7
#define RUBY_RELEASE_DAY 18
#include "ruby/version.h"