Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WasiProcess::terminate() #4397

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/types/src/compilation/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use target_lexicon::{
///
/// [`cpuid` crate]: https://docs.rs/cpuid/0.1.1/cpuid/enum.CpuFeature.html
/// [`cranelift-native`]: https://github.com/bytecodealliance/cranelift/blob/6988545fd20249b084c53f4761b8c861266f5d31/cranelift-native/src/lib.rs#L51-L92
#[allow(missing_docs, clippy::derive_hash_xor_eq)]
#[allow(missing_docs, clippy::derived_hash_with_manual_eq)]
#[derive(EnumSetType, Debug, Hash)]
pub enum CpuFeature {
// X86 features
Expand Down
8 changes: 4 additions & 4 deletions lib/vm/src/trap/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Trap {
pub fn downcast<T: Error + 'static>(self) -> Result<T, Self> {
match self {
// We only try to downcast user errors
Trap::User(err) if err.is::<T>() => Ok(*err.downcast::<T>().unwrap()),
Self::User(err) if err.is::<T>() => Ok(*err.downcast::<T>().unwrap()),
_ => Err(self),
}
}
Expand All @@ -100,15 +100,15 @@ impl Trap {
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
match &self {
// We only try to downcast user errors
Trap::User(err) if err.is::<T>() => err.downcast_ref::<T>(),
Self::User(err) if err.is::<T>() => err.downcast_ref::<T>(),
_ => None,
}
}

/// Returns true if the `Trap` is the same as T
pub fn is<T: Error + 'static>(&self) -> bool {
match self {
Trap::User(err) => err.is::<T>(),
Self::User(err) => err.is::<T>(),
_ => false,
}
}
Expand All @@ -117,7 +117,7 @@ impl Trap {
impl std::error::Error for Trap {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
Trap::User(err) => Some(&**err),
Self::User(err) => Some(&**err),
_ => None,
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/wasix/src/os/task/control_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ impl WasiControlPlane {
}

// Create the process first to do all the allocations before locking.
let mut proc = WasiProcess::new(WasiProcessId::from(0), module_hash, self.handle());

let mut mutable = self.state.mutable.write().unwrap();

let pid = mutable.next_process_id()?;
proc.set_pid(pid);
let proc = WasiProcess::new(pid, module_hash, self.handle());
mutable.processes.insert(pid, proc.clone());
Ok(proc)
}
Expand Down
Loading
Loading