Skip to content

Commit 7fb684a

Browse files
committed
review: add comments explaining Arc::get_mut limitations
1 parent 890c825 commit 7fb684a

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
@@ -473,6 +473,13 @@ fn populate_with_wasi(
473473
#[cfg(feature = "wasi-crypto")]
474474
{
475475
wasmtime_wasi_crypto::add_to_linker(linker, |host| {
476+
// This WASI proposal is currently not protected against
477+
// concurrent access--i.e., when wasi-threads is actively
478+
// spawning new threads, we cannot (yet) safely allow access and
479+
// fail if more than one thread has `Arc`-references to the
480+
// context. Once this proposal is updated (as wasi-common has
481+
// been) to allow concurrent access, this `Arc::get_mut`
482+
// limitation can be removed.
476483
Arc::get_mut(host.wasi_crypto.as_mut().unwrap())
477484
.expect("wasi-crypto is not implemented with multi-threading support")
478485
})?;
@@ -488,6 +495,7 @@ fn populate_with_wasi(
488495
#[cfg(feature = "wasi-nn")]
489496
{
490497
wasmtime_wasi_nn::add_to_linker(linker, |host| {
498+
// See documentation for wasi-crypto for why this is needed.
491499
Arc::get_mut(host.wasi_nn.as_mut().unwrap())
492500
.expect("wasi-nn is not implemented with multi-threading support")
493501
})?;

0 commit comments

Comments
 (0)