From 963d88a79d0d6b3b4f5562f72b857630d05ac93c Mon Sep 17 00:00:00 2001 From: Greg Morenz Date: Mon, 3 Mar 2025 00:29:38 -0500 Subject: [PATCH] Use Arc::get_mut instead of Arc::strong_count == 1 (#555) Arc::strong_count doesn't come with memory ordering guarantees. As such it should be possible to destory the context multiple times with the previous version of this check. See https://github.com/rust-lang/rust/issues/117485 Signed-off-by: Greg Morenz --- mozjs/src/rust.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mozjs/src/rust.rs b/mozjs/src/rust.rs index bfa2ab0c20..81b3ff1463 100644 --- a/mozjs/src/rust.rs +++ b/mozjs/src/rust.rs @@ -428,9 +428,8 @@ impl Runtime { impl Drop for Runtime { fn drop(&mut self) { self.thread_safe_handle.write().unwrap().take(); - assert_eq!( - Arc::strong_count(&self.outstanding_children), - 1, + assert!( + Arc::get_mut(&mut self.outstanding_children).is_some(), "This runtime still has live children." ); unsafe {