diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2022-08-10 17:22:55 -0400 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 08:47:10 -0700 |
commit | 4d811d7a2b92d110e3e70cb77e5f499acfa7112a (patch) | |
tree | 122afcc90f7416832322df48276636de6d592fcb /yjit/src/yjit.rs | |
parent | ee1697ee0727c29fc61c88ccb6036aa763d2d2b6 (diff) | |
download | ruby-4d811d7a2b92d110e3e70cb77e5f499acfa7112a.tar.gz |
Fix code invalidation while OOM and OOM simulation (https://github.com/Shopify/ruby/pull/395)
`YJIT.simulate_oom!` used to leave one byte of space in the code block,
so our test didn't expose a problem with asserting that the write
position is in bounds in `CodeBlock::set_pos`. We do the following when
patching code:
1. save current write position
2. seek to middle of the code block and patch
3. restore old write position
The bounds check fails on (3) when the code block is already filled up.
Leaving one byte of space also meant that when we write that byte, we
need to fill the entire code region with trapping instruction in
`VirtualMem`, which made the OOM tests unnecessarily slow.
Remove the incorrect bounds check and stop leaving space in the code
block when simulating OOM.
Diffstat (limited to 'yjit/src/yjit.rs')
-rw-r--r-- | yjit/src/yjit.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/yjit/src/yjit.rs b/yjit/src/yjit.rs index bfa9188d3e..5cd23f066f 100644 --- a/yjit/src/yjit.rs +++ b/yjit/src/yjit.rs @@ -91,8 +91,8 @@ pub extern "C" fn rb_yjit_simulate_oom_bang(_ec: EcPtr, _ruby_self: VALUE) -> VA if cfg!(debug_assertions) { let cb = CodegenGlobals::get_inline_cb(); let ocb = CodegenGlobals::get_outlined_cb().unwrap(); - cb.set_pos(cb.get_mem_size() - 1); - ocb.set_pos(ocb.get_mem_size() - 1); + cb.set_pos(cb.get_mem_size()); + ocb.set_pos(ocb.get_mem_size()); } return Qnil; |