summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-08-10 17:22:55 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2022-08-29 08:47:10 -0700
commit4d811d7a2b92d110e3e70cb77e5f499acfa7112a (patch)
tree122afcc90f7416832322df48276636de6d592fcb /bootstraptest
parentee1697ee0727c29fc61c88ccb6036aa763d2d2b6 (diff)
downloadruby-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 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index d44fe25800..89d7c9a038 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -2901,11 +2901,20 @@ assert_equal 'new', %q{
foo
end
+ def bar
+ :bar
+ end
+
+
test
test
RubyVM::YJIT.simulate_oom! if defined?(RubyVM::YJIT)
+ # Old simulat_omm! leaves one byte of space and this fills it up
+ bar
+ bar
+
def foo
:new
end