mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
a1a07945d6
The first leak: ```rust #[test] fn blob_vec_drop_empty_capacity() { let item_layout = Layout:🆕:<Foo>(); let drop = drop_ptr::<Foo>; let _ = unsafe { BlobVec::new(item_layout, Some(drop), 0) }; } ``` this is because we allocate the swap scratch in blobvec regardless of what the capacity is, but we only deallocate if capacity is > 0 The second leak: ```rust #[test] fn panic_while_overwriting_component() { let helper = DropTestHelper::new(); let res = panic::catch_unwind(|| { let mut world = World::new(); world .spawn() .insert(helper.make_component(true, 0)) .insert(helper.make_component(false, 1)); println!("Done inserting! Dropping world..."); }); let drop_log = helper.finish(res); assert_eq!( &*drop_log, [ DropLogItem::Create(0), DropLogItem::Create(1), DropLogItem::Drop(0), ] ); } ``` this is caused by us not running the drop impl on the to-be-inserted component if the drop impl of the overwritten component panics --- managed to figure out where the leaks were by using this 10/10 command ``` cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation" xargs -n1 cargo miri test --lib -- --exact ``` which runs every test one by one rather than all at once which let miri actually tell me which test had the leak 🙃 |
||
---|---|---|
.. | ||
contributing | ||
example-run | ||
ISSUE_TEMPLATE | ||
linters | ||
start-wasm-example | ||
workflows | ||
bors.toml | ||
dependabot.yml | ||
FUNDING.yml | ||
pull_request_template.md |