Skip to content

Commit 1db9948

Browse files
committed
review: add comments explaining Arc::get_mut limitations
1 parent 2d7107c commit 1db9948

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/commands/run.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,13 @@ fn populate_with_wasi(
472472
#[cfg(feature = "wasi-crypto")]
473473
{
474474
wasmtime_wasi_crypto::add_to_linker(linker, |host| {
475+
// This WASI proposal is currently not protected against
476+
// concurrent access--i.e., when wasi-threads is actively
477+
// spawning new threads, we cannot (yet) safely allow access and
478+
// fail if more than one thread has `Arc`-references to the
479+
// context. Once this proposal is updated (as wasi-common has
480+
// been) to allow concurrent access, this `Arc::get_mut`
481+
// limitation can be removed.
475482
Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
476483
.expect("wasi-crypto is not implemented with multi-threading support")
477484
})?;
@@ -487,6 +494,7 @@ fn populate_with_wasi(
487494
#[cfg(feature = "wasi-nn")]
488495
{
489496
wasmtime_wasi_nn::add_to_linker(linker, |host| {
497+
// See documentation for wasi-crypto for why this is needed.
490498
Arc::get_mut(host.wasi_nn.as_mut().unwrap())
491499
.expect("wasi-nn is not implemented with multi-threading support")
492500
})?;

0 commit comments

Comments
 (0)