-
Notifications
You must be signed in to change notification settings - Fork 166
Closed
Description
@Stebalien discovered panic safety issue bluss/arrayvec#3 and it applies to smallvec as well.
My understanding is: SmallVec::drop first attempts to drop every element, then it inhibits the drop of the inner array. The panic safety issue is that a panic during drop of an element means the inhibition is never reached, so the inner data can be dropped again.
Testcase adapted from @Stebalien
#[test]
#[should_panic]
fn test_drop_panic_smallvec() {
// This test should only panic once, and not double panic,
// which would mean a double drop
struct DropPanic;
impl Drop for DropPanic {
fn drop(&mut self) {
panic!("drop");
}
}
let mut v = SmallVec::<[_; 1]>::new();
v.push(DropPanic);
}Metadata
Metadata
Assignees
Labels
No labels