Skip to content

Commit c83456f

Browse files
committed
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 rust-lang/rust#117485
1 parent 87cabf4 commit c83456f

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
@@ -431,9 +431,8 @@ impl Runtime {
431431
impl Drop for Runtime {
432432
fn drop(&mut self) {
433433
self.thread_safe_handle.write().unwrap().take();
434-
assert_eq!(
435-
Arc::strong_count(&self.outstanding_children),
436-
1,
434+
assert!(
435+
Arc::get_mut(&mut self.outstanding_children).is_some(),
437436
"This runtime still has live children."
438437
);
439438
unsafe {

0 commit comments

Comments
 (0)