()
| 1471 | #[test] |
| 1472 | #[cfg_attr(any(miri, not(target_pointer_width = "64")), ignore)] |
| 1473 | fn gc_heap_oom() -> Result<()> { |
| 1474 | if std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok() { |
| 1475 | return Ok(()); |
| 1476 | } |
| 1477 | |
| 1478 | let _ = env_logger::try_init(); |
| 1479 | |
| 1480 | for heap_size in [ |
| 1481 | // Very small heap. |
| 1482 | 1 << 16, |
| 1483 | // Bigger heap: 4 GiB |
| 1484 | 1 << 32, |
| 1485 | ] { |
| 1486 | for pooling in [true, false] { |
| 1487 | let mut config = Config::new(); |
| 1488 | config.wasm_function_references(true); |
| 1489 | config.wasm_gc(true); |
| 1490 | config.collector(Collector::Null); |
| 1491 | config.memory_reservation(heap_size); |
| 1492 | config.memory_reservation_for_growth(0); |
| 1493 | config.memory_guard_size(0); |
| 1494 | config.memory_may_move(false); |
| 1495 | config.gc_heap_reservation(heap_size); |
| 1496 | config.gc_heap_reservation_for_growth(0); |
| 1497 | config.gc_heap_guard_size(0); |
| 1498 | config.gc_heap_may_move(false); |
| 1499 | |
| 1500 | if pooling { |
| 1501 | let mut pooling = crate::small_pool_config(); |
| 1502 | pooling.max_memory_size(heap_size.try_into().unwrap()); |
| 1503 | config.allocation_strategy(InstanceAllocationStrategy::Pooling(pooling)); |
| 1504 | } |
| 1505 | |
| 1506 | let engine = Engine::new(&config)?; |
| 1507 | |
| 1508 | let module = Module::new( |
| 1509 | &engine, |
| 1510 | r#" |
| 1511 | (module |
| 1512 | (type $s (struct)) |
| 1513 | (global $g (export "g") (mut i32) (i32.const 0)) |
| 1514 | (func (export "run") |
| 1515 | loop |
| 1516 | struct.new $s |
| 1517 | |
| 1518 | global.get $g |
| 1519 | i32.const 1 |
| 1520 | i32.add |
| 1521 | global.set $g |
| 1522 | |
| 1523 | br 0 |
| 1524 | end |
| 1525 | ) |
| 1526 | ) |
| 1527 | "#, |
| 1528 | )?; |
| 1529 | |
| 1530 | let mut store = Store::new(&engine, ()); |
nothing calls this directly
no test coverage detected