You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warns about a field in a Send struct that is neither Send nor Copy.
Sending the struct to another thread and drops it there will also drop the field in the new thread. This effectively changes the ownership of the field type and breaks the non-Send requirement which is unsound.
This is one of the most common unsound bug patterns we observed during Rudra project.
Raw pointers in data structures could cause false positives, such as Vec<*const T>. They can be partially mitigated by checking if any pointer type is used as a generic type parameter.
A field that implements Copy but not Send can actually be a problem, e.g., RUSTSEC-2020-0136. However, they would be better handled in a separate lint because this lint focuses on unsoundness in drop and removing the Copy bound would cause too much false positives.
Example
// Example from google/async-coap, RUSTSEC-2020-0124#[derive(Debug,Clone)]pubstructArcGuard<RC,T>{inner:T,head:Arc<RC>,// This drops Arc<RC> (and in turn RC) which might not be `Send`}unsafeimpl<RC,T:Send>SendforArcGuard<RC,T>{}// There is no `RC: Send` bound here
What it does
Warns about a field in a
Send
struct that is neitherSend
norCopy
.Sending the struct to another thread and drops it there will also drop the field in the new thread. This effectively changes the ownership of the field type and breaks the non-
Send
requirement which is unsound.This is one of the most common unsound bug patterns we observed during Rudra project.
Bug examples:
Categories (optional)
Known Problems
Vec<*const T>
. They can be partially mitigated by checking if any pointer type is used as a generic type parameter.Copy
but notSend
can actually be a problem, e.g., RUSTSEC-2020-0136. However, they would be better handled in a separate lint because this lint focuses on unsoundness in drop and removing theCopy
bound would cause too much false positives.Example
@rustbot claim
The text was updated successfully, but these errors were encountered: