ruby-changes:70069
From: Alan <ko1@a...>
Date: Mon, 6 Dec 2021 00:26:55 +0900 (JST)
Subject: [ruby-changes:70069] 26063d3954 (master): YJIT: Initialize code buffer with PUSH DS
https://git.ruby-lang.org/ruby.git/commit/?id=26063d3954 From 26063d39546ccd6d0b9d42defc2ad1bb8d35cc27 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Sun, 5 Dec 2021 10:08:19 -0500 Subject: YJIT: Initialize code buffer with PUSH DS PUSH DS triggers the #UD processor exception in 64-bit mode, which the OS translates to a SIGILL. Unlike INT3, this triggers the usual crash reporter, which makes failures easier to notice. When there is a debugger attached, the PUSH DS pauses execution just like INT3. --- yjit_asm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yjit_asm.c b/yjit_asm.c index 98f4a4e5157..3a43c80ef08 100644 --- a/yjit_asm.c +++ b/yjit_asm.c @@ -215,10 +215,11 @@ static uint8_t *alloc_exec_mem(uint32_t mem_size) https://github.com/ruby/ruby/blob/trunk/yjit_asm.c#L215 cb_init(cb, mem_block, mem_size); - // Fill the executable memory with INT3 (0xCC) so that - // executing uninitialized memory will fault + // Fill the executable memory with PUSH DS (0x1E) so that + // executing uninitialized memory will fault with #UD in + // 64-bit mode. cb_mark_all_writeable(cb); - memset(mem_block, 0xCC, mem_size); + memset(mem_block, 0x1E, mem_size); cb_mark_all_executable(cb); return mem_block; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/