Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix insufficient synchronization in examples #30

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

JoJoDeveloping
Copy link
Contributor

The examples use Arc::strong_count in order to await all other threads having terminated. Unfortunately, Arc::strong_count uses a Relaxed atomic to load the value, so this can not be used to establish an ordering, and later leads to a weak memory data race. The alternative is to use Arc::get_mut, which uses the internal is_unique function, which is unfortunately private and therefore not usable directly.

The examples use `Arc::strong_count` in order to await all other threads
having terminated. Unfortunately, `Arc::strong_count` uses a `Relaxed`
atomic to load the value, so this can not be used to establish an
ordering, and later leads to a weak memory data race. The alternative
is to use `get_mut`, which uses the internal `is_unique` function, which
is unfortunately private and therefore not usable directly.
@al8n
Copy link
Owner

al8n commented Aug 28, 2024

Thanks!

@al8n al8n merged commit b2eb642 into al8n:main Aug 28, 2024
22 of 24 checks passed
@JoJoDeveloping
Copy link
Contributor Author

JoJoDeveloping commented Aug 28, 2024

Oh no, you were to quick 🚀 I just saw the same problem is present in src/map/tests.rs, but before I could fix it you merged it already 😆

But thanks for merging!

JoJoDeveloping added a commit to JoJoDeveloping/skl that referenced this pull request Aug 28, 2024
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.14%. Comparing base (bcd0436) to head (e20be2c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
- Coverage   79.22%   79.14%   -0.08%     
==========================================
  Files           9        9              
  Lines        2609     2609              
==========================================
- Hits         2067     2065       -2     
- Misses        542      544       +2     

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bcd0436...e20be2c. Read the comment docs.

@JoJoDeveloping
Copy link
Contributor Author

This is another instance of rust-lang/rust#117485, mentioning this here so it is referenced there..

al8n pushed a commit that referenced this pull request Sep 5, 2024
…unnable under miri (#31)

* Fix #30 in tests also

* Make tests pass under miri in a reasonable time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants