summaryrefslogtreecommitdiff
path: root/bootstraptest/test_yjit.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-04-06 19:14:03 -0700
committerGitHub <noreply@github.com>2022-04-06 19:14:03 -0700
commit0b091fdac6ceb33b7379ceddc9a49a79d0e158b2 (patch)
tree3ec9799bb7c38ce87b24380f8008ed07467f48e5 /bootstraptest/test_yjit.rb
parentbff12e1a9a726baef8d5d8876669a1506555ec09 (diff)
Raise RuntimeError if Kernel#binding is called from a non-Ruby frame
Check whether the current or previous frame is a Ruby frame in call_trace_func and rb_tracearg_binding before attempting to create a binding for the frame. Fixes [Bug #18487] Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5767 Merged-By: jeremyevans <code@jeremyevans.net>
Diffstat (limited to 'bootstraptest/test_yjit.rb')
-rw-r--r--bootstraptest/test_yjit.rb31
1 files changed, 0 insertions, 31 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index d124d180d1..a84a9e035a 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1,34 +1,3 @@
-assert_equal '2022', %q{
- def contrivance(hash, key)
- # Expect this to compile to an `opt_aref`.
- hash[key]
-
- # The [] call above tracks that the `hash` local has a VALUE that
- # is a heap pointer and the guard for the Kernel#itself call below
- # doesn't check that it's a heap pointer VALUE.
- #
- # As you can see from the crash, the call to rb_hash_aref() can set the
- # `hash` local, making eliding the heap object guard unsound.
- hash.itself
- end
-
- # This is similar to ->(recv, mid) { send(recv, mid).local_variable_set(...) }.
- # By composing we avoid creating new Ruby frames and so sending :binding
- # captures the environment of the frame that does the missing key lookup.
- # We use it to capture the environment inside of `contrivance`.
- cap_then_set =
- Kernel.instance_method(:send).method(:bind_call).to_proc >>
- ->(binding) { binding.local_variable_set(:hash, 2022) }
- special_missing = Hash.new(&cap_then_set)
-
- # Make YJIT speculate that it's a hash and generate code
- # that calls rb_hash_aref().
- contrivance({}, :warmup)
- contrivance({}, :warmup)
-
- contrivance(special_missing, :binding)
-}
-
assert_equal '18374962167983112447', %q{
# regression test for incorrectly discarding 32 bits of a pointer when it
# comes to default values.