Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Avoid `copy_from_slice` in the p1 adapter (#12088)

Alex Crichton33cbb217ebec
diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml
index 44dbbd4b24..d3219569df 100644
--- a/.github/actions/install-rust/action.yml
+++ b/.github/actions/install-rust/action.yml
@@ -32,7 +32,7 @@ runs:
elif [ "${{ inputs.toolchain }}" = "msrv" ]; then
echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.toolchain }}" = "wasmtime-ci-pinned-nightly" ]; then
- echo "version=nightly-2025-11-01" >> "$GITHUB_OUTPUT"
+ echo "version=nightly-2025-11-25" >> "$GITHUB_OUTPUT"
else
echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT"
fi
diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rs
index 9d060710fb..115081eb59 100644
--- a/cranelift/filetests/src/function_runner.rs
+++ b/cranelift/filetests/src/function_runner.rs
@@ -292,7 +292,7 @@ impl TestFileCompiler {
let ext_func = &cursor.func.dfg.ext_funcs[*func_ref];
let hostcall_addr = match &ext_func.name {
ExternalName::TestCase(tc) if tc.raw() == b"__cranelift_throw" => {
- Some(__cranelift_throw as usize)
+ Some((__cranelift_throw as *const ()).addr())
}
_ => None,
};
diff --git a/crates/wasi-preview1-component-adapter/src/lib.rs b/crates/wasi-preview1-component-adapter/src/lib.rs
index d744c0d659..5d6e14b788 100644
--- a/crates/wasi-preview1-component-adapter/src/lib.rs
+++ b/crates/wasi-preview1-component-adapter/src/lib.rs
@@ -1431,7 +1431,9 @@ pub unsafe extern "C" fn fd_readdir(
)
};
let dirent_bytes_to_copy = buf.len().min(bytes.len());
- buf[..dirent_bytes_to_copy].copy_from_slice(&bytes[..dirent_bytes_to_copy]);
+ unsafe {
+ ptr::copy_nonoverlapping(bytes.as_ptr(), buf.as_mut_ptr(), dirent_bytes_to_copy);
+ }
buf = &mut buf[dirent_bytes_to_copy..];
// Copy the name bytes into the output `buf`, truncating it if it
diff --git a/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs b/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
index 300af997d9..2c3aef922d 100644
--- a/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
+++ b/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
@@ -258,7 +258,7 @@ impl VMContinuationStack {
let to_store = [
// Data near top of stack:
- (0x08, wasmtime_continuation_start as usize),
+ (0x08, (wasmtime_continuation_start as *const ()).addr()),
(0x10, tos.sub(0x10).addr()),
(0x18, tos.sub(0x40 + args_data_size).addr()),
(0x20, usize::try_from(args_capacity).unwrap()),
diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/machports.rs b/crates/wasmtime/src/runtime/vm/sys/unix/machports.rs
index 8634624cad..dcec33fbc0 100644
--- a/crates/wasmtime/src/runtime/vm/sys/unix/machports.rs
+++ b/crates/wasmtime/src/runtime/vm/sys/unix/machports.rs
@@ -102,7 +102,7 @@ impl TrapHandler {
// overflowed when a host overflows its fiber stack.
let mut handler: libc::sigaction = mem::zeroed();
handler.sa_flags = libc::SA_SIGINFO | libc::SA_ONSTACK;
- handler.sa_sigaction = sigbus_handler as usize;
+ handler.sa_sigaction = (sigbus_handler as *const ()).addr();
libc::sigemptyset(&mut handler.sa_mask);
if libc::sigaction(libc::SIGBUS, &handler, &raw mut PREV_SIGBUS) != 0 {
panic!(
@@ -351,7 +351,7 @@ unsafe fn handle_exception(request: &mut ExceptionRequest) -> bool {
*(state.__rsp as *mut u64) = state.__rip;
}
}
- state.__rip = unwind as u64;
+ state.__rip = (unwind as *const ()).addr() as u64;
state.__rdi = pc as u64;
state.__rsi = fp as u64;
state.__rdx = fault1 as u64;
@@ -383,7 +383,7 @@ unsafe fn handle_exception(request: &mut ExceptionRequest) -> bool {
state.__x[2] = fault1 as u64;
state.__x[3] = fault2 as u64;
state.__x[4] = trap as u64;
- state.__pc = unwind as u64;
+ state.__pc = (unwind as *const ()).addr() as u64;
};
let mut thread_state = unsafe { mem::zeroed::<ThreadState>() };
} else {
diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs b/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs
index be7fb6c899..bc7b9c599c 100644
--- a/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs
+++ b/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs
@@ -49,7 +49,7 @@ impl TrapHandler {
// crash while handling the signal, and fall through to the
// Breakpad handler by testing handlingSegFault.
handler.sa_flags = libc::SA_SIGINFO | libc::SA_NODEFER | libc::SA_ONSTACK;
- handler.sa_sigaction = trap_handler as usize;
+ handler.sa_sigaction = (trap_handler as *const ()).addr();
unsafe {
libc::sigemptyset(&mut handler.sa_mask);
if libc::sigaction(signal, &handler, slot) != 0 {
@@ -111,7 +111,7 @@ impl Drop for TrapHandler {
// signal handler state and don't know how to remove ourselves
// from the signal handling state. Inform the user of this and
// abort the process.
- if prev.sa_sigaction != trap_handler as usize {
+ if prev.sa_sigaction != (trap_handler as *const ()).addr() {
eprintln!(
"
Wasmtime's signal handler was not the last signal handler to be installed