From 4e62f07cc8b053d4a2d4abd5aa976bef38b2d144 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Wed, 9 Oct 2019 14:37:41 +0300 Subject: [PATCH] [sgen] Fix invalid value passed to write barrier (mono/mono#17236) When doing memory copy dest is the destination address and src is the source address. If we are copying a single reference, we need to emit a write barrier and pass to the write barrier the value, not the pointer where the value is stored. Commit migrated from https://github.com/mono/mono/commit/8e649c35450e77e68ff468ced77987e4c0b51f99 --- src/mono/mono/mini/memory-access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/memory-access.c b/src/mono/mono/mini/memory-access.c index 7d1e42f..da695ad 100644 --- a/src/mono/mono/mini/memory-access.c +++ b/src/mono/mono/mini/memory-access.c @@ -400,7 +400,7 @@ mini_emit_memory_copy_internal (MonoCompile *cfg, MonoInst *dest, MonoInst *src, NEW_STORE_MEMBASE (cfg, store, OP_STORE_MEMBASE_REG, dest->dreg, 0, dreg); MONO_ADD_INS (cfg->cbb, store); - mini_emit_write_barrier (cfg, dest, src); + mini_emit_write_barrier (cfg, dest, load); return; } else if (cfg->gen_write_barriers && (m_class_has_references (klass) || size_ins) && !native) { /* if native is true there should be no references in the struct */ -- 2.7.4