From 32bf5ca1bbabb1a1c695aaccbcc664bdc5fd711b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 24 Jul 2019 12:20:43 +0200 Subject: [PATCH 1/2] Don't insta-free in UniqueArc::assume_init. --- components/servo_arc/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index 6e86ea7b5f3..1567fd3d421 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -144,7 +144,7 @@ impl UniqueArc> { #[inline] pub unsafe fn assume_init(this: Self) -> UniqueArc { UniqueArc(Arc { - p: this.0.p.cast(), + p: mem::ManuallyDrop::new(this).0.p.cast(), phantom: PhantomData, }) } From 62907afe1c6752f3b70fe7fabc288de09afb1866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 24 Jul 2019 13:42:45 +0200 Subject: [PATCH 2/2] style: Properly refcount-log UniqueArcs created with new_uninitialized(). --- components/servo_arc/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index 1567fd3d421..ad4489c10bc 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -125,6 +125,12 @@ impl UniqueArc { .unwrap_or_else(|| alloc::handle_alloc_error(layout)) .cast::>>(); ptr::write(&mut p.as_mut().count, atomic::AtomicUsize::new(1)); + + #[cfg(feature = "gecko_refcount_logging")] + { + NS_LogCtor(p.as_ptr() as *mut _, b"ServoArc\0".as_ptr() as *const _, 8) + } + UniqueArc(Arc { p, phantom: PhantomData,