Skip to content

Commit 963d88a

Browse files
authored
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 rust-lang/rust#117485 Signed-off-by: Greg Morenz <[email protected]>
1 parent 6147231 commit 963d88a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mozjs/src/rust.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,8 @@ impl Runtime {
428428
impl Drop for Runtime {
429429
fn drop(&mut self) {
430430
self.thread_safe_handle.write().unwrap().take();
431-
assert_eq!(
432-
Arc::strong_count(&self.outstanding_children),
433-
1,
431+
assert!(
432+
Arc::get_mut(&mut self.outstanding_children).is_some(),
434433
"This runtime still has live children."
435434
);
436435
unsafe {

0 commit comments

Comments
 (0)