diff options
author | Takashi Kokubun <[email protected]> | 2024-02-23 20:18:41 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2024-02-23 20:19:37 -0800 |
commit | e9e752c7efe95e7166c7bb59277b6e3afe11851c (patch) | |
tree | 5308aa6853b4f4aef4062bf9d0a9b2d1b87f3a6b /yjit/src/core.rs | |
parent | 804b2a3787e17ccc4537b4c525d4f81adc27ab7c (diff) |
Assert running_iseq before using it
When running_iseq happens to be 0, it's better to fail on the assertion
rather than referencing the null pointer.
Diffstat (limited to 'yjit/src/core.rs')
-rw-r--r-- | yjit/src/core.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs index 3843e91e2e..90e6490997 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -2749,14 +2749,14 @@ fn branch_stub_hit_body(branch_ptr: *const c_void, target_idx: u32, ec: EcPtr) - let original_interp_sp = get_cfp_sp(cfp); let running_iseq = get_cfp_iseq(cfp); + assert_eq!(running_iseq, target_blockid.iseq as _, "each stub expects a particular iseq"); + let reconned_pc = rb_iseq_pc_at_idx(running_iseq, target_blockid.idx.into()); let reconned_sp = original_interp_sp.offset(target_ctx.sp_offset.into()); // Unlike in the interpreter, our `leave` doesn't write to the caller's // SP -- we do it in the returned-to code. Account for this difference. let reconned_sp = reconned_sp.add(target_ctx.is_return_landing().into()); - assert_eq!(running_iseq, target_blockid.iseq as _, "each stub expects a particular iseq"); - // Update the PC in the current CFP, because it may be out of sync in JITted code rb_set_cfp_pc(cfp, reconned_pc); |