FyroxEngine / Fyrox

3D and 2D game engine written in Rust

Home Page:https://fyrox.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle<T>unconditionally implements Send/Sync

kuzeyardabulut opened this issue · comments

Hi,
I found a memory-safety/soundness issue in this crate while scanning Rust code for potential vulnerabilities. This PR contains a fix for the issue.

Issue Description

Handle<T> unconditionally implements Sync. This allows users to create data races on T: !Sync. Such data races can lead to undefined behavior.

unsafe impl<T> Send for Handle<T> {}
unsafe impl<T> Sync for Handle<T> {}

This may not cause a direct data race. But making changes can be useful.

It is impossible to get data races in Handle struct, because its fields are just both u32 which both Send + Sync. This unsafe impl is needed just to implement Send + Sync for PhantomData<T>. Any objections?