Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2023-07-02
toolchain: nightly-2023-10-10

# Build C API documentation
- run: curl -L https://sourceforge.net/projects/doxygen/files/rel-1.9.3/doxygen-1.9.3.linux.bin.tar.gz/download | tar xzf -
Expand Down Expand Up @@ -347,7 +347,7 @@ jobs:
# flags to rustc.
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2023-07-02
toolchain: nightly-2023-10-10
- run: cargo install cargo-fuzz --vers "^0.11"
# Install the OCaml packages necessary for fuzz targets that use the
# `wasm-spec-interpreter`.
Expand Down Expand Up @@ -628,7 +628,7 @@ jobs:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2023-07-02
toolchain: nightly-2023-10-10
- run: rustup component add rust-src miri
- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ authors = ["The Wasmtime Project Developers"]
edition = "2021"
# Wasmtime's current policy is that this number can be no larger than the
# current stable release of Rust minus 2.
rust-version = "1.70.0"
rust-version = "1.71.0"

[workspace.dependencies]
wasmtime-wmemcheck = { path = "crates/wmemcheck", version = "=15.0.0" }
Expand Down
6 changes: 0 additions & 6 deletions ci/build-test-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ const array = [
"name": "Test Linux riscv64",
"filter": "linux-riscv64",
"isa": "riscv64",
// There appears to be a miscompile in Rust 1.72 for riscv64 where
// wasmtime-wasi tests are segfaulting in CI with the stack pointing in
// Tokio. Updating rustc seems to do the trick, so without doing a full
// rigorous investigation this uses beta for now but Rust 1.73 should be
// good to go for this.
"rust": "beta-2023-09-10",
}
];

Expand Down
16 changes: 10 additions & 6 deletions crates/runtime/src/instance/allocator/pooling/table_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use super::{
index_allocator::{SimpleIndexAllocator, SlotId},
round_up_to_pow2, TableAllocationIndex,
};
use crate::{InstanceAllocationRequest, Mmap, PoolingInstanceAllocatorConfig, Table};
use crate::{InstanceAllocationRequest, Mmap, PoolingInstanceAllocatorConfig, SendSyncPtr, Table};
use anyhow::{anyhow, bail, Context, Result};
use std::mem;
use std::ptr::NonNull;
use wasmtime_environ::{Module, TablePlan};

/// Represents a pool of WebAssembly tables.
Expand Down Expand Up @@ -133,11 +134,14 @@ impl TablePool {
self.table_elements * mem::size_of::<*mut u8>(),
)?;

Table::new_static(
table_plan,
unsafe { std::slice::from_raw_parts_mut(base.cast(), self.table_elements) },
unsafe { &mut *request.store.get().unwrap() },
)
let ptr = NonNull::new(std::ptr::slice_from_raw_parts_mut(
base.cast(),
self.table_elements,
))
.unwrap();
Table::new_static(table_plan, SendSyncPtr::new(ptr), unsafe {
&mut *request.store.get().unwrap()
})
})() {
Ok(table) => Ok((allocation_index, table)),
Err(e) => {
Expand Down
7 changes: 7 additions & 0 deletions crates/runtime/src/send_sync_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ impl<T: ?Sized> SendSyncPtr<T> {
}
}

impl<T> SendSyncPtr<[T]> {
/// Returns the slice's length component of the pointer.
pub fn len(&self) -> usize {
self.0.len()
}
}

impl<T: ?Sized, U> From<U> for SendSyncPtr<T>
where
U: Into<NonNull<T>>,
Expand Down
25 changes: 15 additions & 10 deletions crates/runtime/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub enum Table {
Static {
/// Where data for this table is stored. The length of this list is the
/// maximum size of the table.
data: &'static mut [TableValue],
data: SendSyncPtr<[TableValue]>,
/// The current size of the table.
size: u32,
/// The type of this table.
Expand Down Expand Up @@ -200,7 +200,7 @@ impl Table {
/// Create a new static (immovable) table instance for the specified table plan.
pub fn new_static(
plan: &TablePlan,
data: &'static mut [TableValue],
data: SendSyncPtr<[TableValue]>,
store: &mut dyn Store,
) -> Result<Self> {
Self::limit_new(plan, store)?;
Expand All @@ -215,7 +215,10 @@ impl Table {
);
}
let data = match plan.table.maximum {
Some(max) if (max as usize) < data.len() => &mut data[..max as usize],
Some(max) if (max as usize) < data.len() => {
let ptr = data.as_non_null();
SendSyncPtr::new(NonNull::slice_from_raw_parts(ptr.cast(), max as usize))
}
_ => data,
};

Expand Down Expand Up @@ -383,9 +386,11 @@ impl Table {
// First resize the storage and then fill with the init value
match self {
Table::Static { size, data, .. } => {
debug_assert!(data[*size as usize..new_size as usize]
.iter()
.all(|x| x.is_none()));
unsafe {
debug_assert!(data.as_ref()[*size as usize..new_size as usize]
.iter()
.all(|x| x.is_none()));
}
*size = new_size;
}
Table::Dynamic { elements, .. } => {
Expand Down Expand Up @@ -472,7 +477,7 @@ impl Table {
pub fn vmtable(&mut self) -> VMTableDefinition {
match self {
Table::Static { data, size, .. } => VMTableDefinition {
base: data.as_mut_ptr().cast(),
base: data.as_ptr().cast(),
current_elements: *size,
},
Table::Dynamic { elements, .. } => VMTableDefinition {
Expand All @@ -492,14 +497,14 @@ impl Table {

fn elements(&self) -> &[TableValue] {
match self {
Table::Static { data, size, .. } => &data[..*size as usize],
Table::Static { data, size, .. } => unsafe { &data.as_ref()[..*size as usize] },
Table::Dynamic { elements, .. } => &elements[..],
}
}

fn elements_mut(&mut self) -> &mut [TableValue] {
match self {
Table::Static { data, size, .. } => &mut data[..*size as usize],
Table::Static { data, size, .. } => unsafe { &mut data.as_mut()[..*size as usize] },
Table::Dynamic { elements, .. } => &mut elements[..],
}
}
Expand Down Expand Up @@ -590,7 +595,7 @@ impl Drop for Table {
impl Default for Table {
fn default() -> Self {
Table::Static {
data: &mut [],
data: SendSyncPtr::new(NonNull::from(&mut [])),
size: 0,
ty: TableElementType::Func,
}
Expand Down
6 changes: 6 additions & 0 deletions crates/runtime/src/traphandlers/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ static mut WASMTIME_PORT: mach_port_name_t = MACH_PORT_NULL;
static mut CHILD_OF_FORKED_PROCESS: bool = false;

pub unsafe fn platform_init() {
if cfg!(miri) {
return;
}
// Mach ports do not currently work across forks, so configure Wasmtime to
// panic in `lazy_per_thread_init` if the child attempts to invoke
// WebAssembly.
Expand Down Expand Up @@ -465,6 +468,9 @@ unsafe extern "C" fn unwind(
/// exception handlers to get registered.
#[cold]
pub fn lazy_per_thread_init() {
if cfg!(miri) {
return;
}
unsafe {
assert!(
!CHILD_OF_FORKED_PROCESS,
Expand Down
3 changes: 1 addition & 2 deletions crates/wasi-common/cap-std-sync/src/sched/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// taken the time to improve it. See bug #2880.

use once_cell::sync::Lazy;
use std::ops::Deref;
use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError};
use std::sync::Mutex;
use std::thread;
Expand Down Expand Up @@ -50,7 +49,7 @@ pub async fn poll_oneoff_<'a>(
for s in poll.rw_subscriptions() {
match s {
Subscription::Read(r) => {
if file_is_stdin(r.file.deref()) {
if file_is_stdin(r.file) {
stdin_read_subs.push(r);
} else if r.file.pollable().is_some() {
immediate_reads.push(r);
Expand Down