Skip to content

Commit

Permalink
Use Arc::get_mut instead of Arc::strong_count == 1
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gmorenz committed Mar 2, 2025
1 parent 87cabf4 commit c83456f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mozjs/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c83456f

Please sign in to comment.