From 1c80d808f53e2f0c6dcd5d6994b55ba83895f1b7 Mon Sep 17 00:00:00 2001 From: Greg Morenz Date: Sun, 2 Mar 2025 18:36:47 -0500 Subject: [PATCH] Use Arc::get_mut instead of Arc::strong_count == 1 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 35189e8806..002fbc50fc 100644 --- a/mozjs/src/rust.rs +++ b/mozjs/src/rust.rs @@ -431,9 +431,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 {