diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-02-17 10:24:01 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-03-24 12:31:07 -0700 |
commit | 343ea9967e4a6b279eed6bd8e81ad0bdc747f254 (patch) | |
tree | 96c0a77db135ec1fdd374144e0e00238e2dfc1c3 /bootstraptest | |
parent | 33b13bd9f19ac806c34d428af49a71c1aa286f7e (diff) | |
download | ruby-343ea9967e4a6b279eed6bd8e81ad0bdc747f254.tar.gz |
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 before attempting to create a binding for the frame.
Fixes [Bug #18487]
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 31 |
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. |