Unratedcrates.ioAmendedPublished
Local (Rc) backed strings and byte strings are Send, allowing data races
- Affected
- crates.io hipstr >= 0.5.0, < 0.5.2; >= 0.6.0, < 0.6.1; >= 0.7.0, < 0.7.1; >= 0.8.0, < 0.8.1
- Fixed in
- 0.8.10.5.20.6.10.7.1· Vendor fix available
- Issue
- Affected versions of this crate implemented `Send` for `HipByt ` (and so for `HipStr `, `HipOsStr ` and `HipPath `), and for the internal shared pointer, whenever the backend `B` is `Send`. The thread-local backend `Local` (the `Local*` type aliases) keeps its reference count in a `Cell `, which is `Send` but not `Sync`: such a value could be sent to another thread while a clone stayed behind, and cloning, dropping or checking uniqueness on both threads then updates or reads the count without synchronization. This is a data race (undefined behavior) reachable from safe code, for example: ```rust let mut a = hipstr::LocalHipByt::with_capacity(62); let b = a.clone(); std::thread::scope(|s| { s.spawn(move || { a.as_mut_ptr(); }); drop(b); }); ``` The default, thread-safe types (`HipStr`, `HipByt`, … with the `ThreadSafe` backend) are not affected. Versions before 0.5.0 are not affected either: their `Local` backend was std's `Rc`, which is not `Send`. The flaw was corrected in 0.8.1 by…
Recommended action: Upgrade to 0.8.1, 0.7.1, 0.6.1 or 0.5.2 by release line, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.