| 885 | #[test] |
| 886 | #[cfg_attr(miri, ignore)] |
| 887 | fn table_set_doesnt_leak() -> Result<()> { |
| 888 | let _ = env_logger::try_init(); |
| 889 | |
| 890 | let mut store = Store::<()>::default(); |
| 891 | let flag = Arc::new(AtomicBool::new(false)); |
| 892 | |
| 893 | { |
| 894 | let mut scope = RootScope::new(&mut store); |
| 895 | let table = Table::new( |
| 896 | &mut scope, |
| 897 | TableType::new(RefType::EXTERNREF, 10, Some(10)), |
| 898 | Ref::Extern(None), |
| 899 | )?; |
| 900 | |
| 901 | let x = ExternRef::new(&mut scope, SetFlagOnDrop(flag.clone()))?; |
| 902 | table.set(&mut scope, 2, x.into())?; |
| 903 | table.set(&mut scope, 2, x.into())?; |
| 904 | table.set(&mut scope, 2, Ref::Extern(None))?; |
| 905 | } |
| 906 | |
| 907 | store.gc(None)?; |
| 908 | assert!(flag.load(SeqCst)); |
| 909 | Ok(()) |
| 910 | } |
| 911 | |
| 912 | #[test] |
| 913 | #[cfg_attr(miri, ignore)] |