mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
bbfefd45c6
commit
26063d3954
Notes:
git
2021-12-06 00:27:02 +09:00
1 changed files with 4 additions and 3 deletions
|
@ -215,10 +215,11 @@ static uint8_t *alloc_exec_mem(uint32_t mem_size)
|
|||
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue