-
Notifications
You must be signed in to change notification settings - Fork 14
Description
While trying out the test-framework I've found that WASM modules compiled with Rust 1.76 assume random_get exists:
[host->vm] proxy_on_context_create(root_context_id=1, parent_context_id=0)
[vm->host] random_get() -> (...) status: Unexpected ***THIS IS AN EMPTY PLACEHOLDER***
[vm<-host] random_get() -> (..) return: InternalFailure ***THIS IS AN EMPTY PLACEHOLDER***
[vm->host] proxy_log(level=5, message_data="panicked at library/std/src/sys/wasi/mod.rs:190:37:
random_get failure: Errno { code: 10, name: "BUSY", message: "Device or resource busy." }") status: Unexpected
Error: error while executing at wasm backtrace:
0: 0x35400f - <unknown>!__rust_start_panic
1: 0x353dcf - <unknown>!rust_panic
2: 0x353d02 - <unknown>!std::panicking::rust_panic_with_hook::hc97f08b908247b1d
3: 0x352f06 - <unknown>!std::panicking::begin_panic_handler::{{closure}}::hdd638bdaba0c6bcc
4: 0x352e31 - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h5b392607309abb6a
5: 0x3536d9 - <unknown>!rust_begin_unwind
6: 0x359a53 - <unknown>!core::panicking::panic_fmt::h9fec598e5939a913
7: 0x36055b - <unknown>!core::result::unwrap_failed::hf6fa377d4c4189f7
8: 0x353fcc - <unknown>!std::sys::wasi::hashmap_random_keys::h005380782f2a95d3 ***THIS IS THE RELEVANT ONE***
9: 0x2f1418 - <unknown>!std::hash::random::RandomState::new::KEYS::__getit::{{closure}}::hcefb3649984e942d
10: 0x2f110b - <unknown>!std::sys::common::thread_local::lazy::LazyKeyInner<T>::initialize::h29f987aa14a20853
11: 0x2f7889 - <unknown>!std::sys::common::thread_local::static_local::Key<T>::get::h46125d90ec6d1a87
12: 0x1eb30 - <unknown>!std::hash::random::RandomState::new::KEYS::__getit::h7058f584453fcfdb
13: 0x2f7a52 - <unknown>!std::thread::local::LocalKey<T>::try_with::he989749e1311f98b
14: 0x2f7968 - <unknown>!std::thread::local::LocalKey<T>::with::hf6618a5eeec42590
15: 0x1ebf5 - <unknown>!<std::hash::random::RandomState as core::default::Default>::default::h9ac44d7f5d33df22
16: 0x8850 - <unknown>!<std::collections::hash::map::HashMap<K,V,S> as core::default::Default>::default::h915d2d8435b25d9f
17: 0x36562 - <unknown>!tokenfilter::_initialize::{{closure}}::hed2a02ab21e62030
18: 0x1847d - <unknown>!core::ops::function::FnOnce::call_once::he7da19782bed26e6
19: 0x5bf36 - <unknown>!proxy_wasm::dispatcher::Dispatcher::create_root_context::h8b217841f9e5145f
20: 0x5c87f - <unknown>!proxy_wasm::dispatcher::Dispatcher::on_create_context::he348d9f5cfffda63
21: 0x618af - <unknown>!proxy_wasm::dispatcher::proxy_on_context_create::{{closure}}::hb251467ca6eabcc7
22: 0x8a43b - <unknown>!std::thread::local::LocalKey<T>::try_with::h2782b0d9105d5b2d
23: 0x8a289 - <unknown>!std::thread::local::LocalKey<T>::with::h0f823b49025a9729
24: 0x6183e - <unknown>!proxy_on_context_create
It appears to try to manipulate a hashmap which now assumes !std::sys::wasi::hashmap_random_keys
is usable in wasm32-wasi
targets.
Compiling with an older rust version (i.e. 1.67.0) appears to run into a different issue (environ_sizes_get
in my case), but looking at https://github.com/rust-lang/rust/blob/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys/wasi/mod.rs#L185 it's going to try to make this hostcall no matter what we do.
This pretty much ties in to #2 where 0.2.0 features are getting used more and more often. Mocking out the random_get hostcall does seem to work, but in my trial and error I just always return the same "random" value, so that's not really a usable implementation.