HueCodes opened PR #13772 from HueCodes:hue-issue-7588 to bytecodealliance:main:
Fixes #7588.
CompiledBlob::perform_relocations` computed relocation targets with unsafe pointer offsets, then cast those pointers back to integers for relocation math.
This computes checked numeric target addresses up front with
ptr.addr().checked_add_signed(...). The relocation math stays the same and unlike #8041 this does not usewrapping_offset.Tested with
cargo test -p cranelift-jit,cargo clippy -p cranelift-jit --all-targets --all-features -- -D warnings, and Cranelift filetests.
HueCodes requested alexcrichton for a review on PR #13772.
HueCodes requested wasmtime-compiler-reviewers for a review on PR #13772.
github-actions[bot] added the label cranelift on PR #13772.
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #13772 Avoid pointer offsets for JIT relocation targets to the merge queue.
:check: alexcrichton merged PR #13772.
alexcrichton removed PR #13772 Avoid pointer offsets for JIT relocation targets from the merge queue.
:memo: bjorn3 submitted PR review.
:speech_balloon: bjorn3 created PR review comment:
This should have used expose_provenance, not addr. addr() doesn't allow dereferencing the address after turning it back into a pointer, yet that is exactly what the JITed code will likely do.
HueCodes commented on PR #13772:
Thanks for the feedback. This is good learning for me.
That makes sense: these relocation values are not just opaque integers for comparison or range math. They can become addresses that JITed code later uses as pointers, so using
addr()drops provenance information that should be exposed for that use case.I prepared a follow-up that switches this helper to
expose_provenance()while leaving the checked addend handling unchanged.
Last updated: Jul 29 2026 at 05:03 UTC