()
| 387 | #[test] |
| 388 | #[cfg_attr(miri, ignore)] |
| 389 | fn private_entity_access() -> wasmtime::Result<()> { |
| 390 | let mut config = Config::default(); |
| 391 | config.guest_debug(true); |
| 392 | config.wasm_gc(true); |
| 393 | config.gc_support(true); |
| 394 | config.wasm_exceptions(true); |
| 395 | let engine = Engine::new(&config)?; |
| 396 | let mut store = Store::new(&engine, ()); |
| 397 | let module = Module::new( |
| 398 | &engine, |
| 399 | r#" |
| 400 | (module |
| 401 | (import "" "i" (global (mut i32))) |
| 402 | (import "" "f" (func (result i32))) |
| 403 | (global $g (mut i32) (i32.const 0)) |
| 404 | (memory $m 1 1) |
| 405 | (table $t 10 10 i31ref) |
| 406 | (tag $tag (param f64)) |
| 407 | (func (export "main") |
| 408 | ;; $g := 42 |
| 409 | i32.const 42 |
| 410 | global.set $g |
| 411 | ;; $m[1024] := 1 |
| 412 | i32.const 1024 |
| 413 | i32.const 1 |
| 414 | i32.store8 $m |
| 415 | ;; $t[1] := (ref.i31 (i32.const 100)) |
| 416 | i32.const 1 |
| 417 | i32.const 100 |
| 418 | ref.i31 |
| 419 | table.set $t) |
| 420 | |
| 421 | (func (param i32) |
| 422 | local.get 0 |
| 423 | global.set $g)) |
| 424 | "#, |
| 425 | )?; |
| 426 | |
| 427 | let host_global = Global::new( |
| 428 | &mut store, |
| 429 | GlobalType::new(ValType::I32, Mutability::Var), |
| 430 | Val::I32(1000), |
| 431 | )?; |
| 432 | let host_func = Func::wrap(&mut store, |_caller: Caller<'_, ()>| -> i32 { 7 }); |
| 433 | |
| 434 | let instance = Instance::new( |
| 435 | &mut store, |
| 436 | &module, |
| 437 | &[Extern::Global(host_global), Extern::Func(host_func)], |
| 438 | )?; |
| 439 | let func = instance.get_func(&mut store, "main").unwrap(); |
| 440 | func.call(&mut store, &[], &mut [])?; |
| 441 | |
| 442 | // Nothing is exported except for `main`, yet we can still access |
| 443 | // (below). |
| 444 | let exports = instance.exports(&mut store).collect::<Vec<_>>(); |
| 445 | assert_eq!(exports.len(), 1); |
| 446 | assert!(exports.into_iter().next().unwrap().into_func().is_some()); |
nothing calls this directly
no test coverage detected