From 1b1ffe3ddf5eb2d2553e81cb9e58f7802f73f727 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 23 Jun 2020 12:06:49 +0200 Subject: [PATCH] Port to 3.1 - Fix JIT_CheckedWriteBarrier on macOS In a change to enable Mojave hardened runtime support that was made last year, a bug was introduced into the JIT_CheckedWriteBarrier. A conditional relative jump before an updated piece of code that was jumping after that piece of code was not updated and ended up jumping into the middle of an instruction. Since that condition occurs only with specific memory layout and it is very rare, that problem was not discovered until now. --- src/vm/amd64/jithelpers_fast.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vm/amd64/jithelpers_fast.S b/src/vm/amd64/jithelpers_fast.S index b81ee373210b..8c76ccc27cd6 100644 --- a/src/vm/amd64/jithelpers_fast.S +++ b/src/vm/amd64/jithelpers_fast.S @@ -33,8 +33,13 @@ LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT // See if this is in GCHeap PREPARE_EXTERNAL_VAR g_lowest_address, rax cmp rdi, [rax] +#ifdef FEATURE_WRITEBARRIER_COPY + // jb NotInHeap + .byte 0x72, 0x12 +#else // jb NotInHeap .byte 0x72, 0x0e +#endif PREPARE_EXTERNAL_VAR g_highest_address, rax cmp rdi, [rax]