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

Unsafe Send and Sync implementations #154

Open
vladbat00 opened this issue Apr 1, 2023 · 1 comment
Open

Unsafe Send and Sync implementations #154

vladbat00 opened this issue Apr 1, 2023 · 1 comment
Labels
bevy adapter pertaining to bevy/naia adapter crates bug needs fixing naia socket pertaining to naia_socket crates naia pertaining to naia crates

Comments

@vladbat00
Copy link

The library marks a lot of types that are explicitly !Send and !Sync (meaning they can't be shared between threads) with unsafe impl Send and unsafe impl Sync. Considering that these types are actively used in the context of Bevy systems and wrapped into resources accessed with Res/ResMut, it's very likely to lead to UB.

Unsafe types in question:
https://github.com/search?q=repo%3Anaia-lib%2Fnaia+%22unsafe+impl%22&type=code

We should remove all the unsafe impl Send and unsafe impl Sync occurrences, even if it means that resources can no longer be accessed from different threads. Bevy supports NonSend, and I'd argue that limiting systems to run only on the main thread is a better compromise than causing UB.

@connorcarpenter
Copy link
Member

I agree, thanks for the call-out @mvlabat 👍 This may take a little bit for me to refactor though. 🙏

@connorcarpenter connorcarpenter added naia pertaining to naia crates bug needs fixing naia socket pertaining to naia_socket crates bevy adapter pertaining to bevy/naia adapter crates labels Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bevy adapter pertaining to bevy/naia adapter crates bug needs fixing naia socket pertaining to naia_socket crates naia pertaining to naia crates
Projects
None yet
Development

No branches or pull requests

2 participants