IssueRaiser

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

github (Other)

struct's lifetime requirements can be bypassed via covariant field assignment

jsnellOct 13, 2026, 8:45 AM

> [!NOTE] > Given that this issue has been shared online and is currently getting quite a few visitors, here's some additional context. > > Rust's type system is intended to prevent memory unsafety. Upholding this promise is something we take very seriously, which is why we've been working on things like [the next-generation trait solver](https://goals.rust-lang.org/2026/next-solver.html), [the region constraint rework](https://goals.rust-lang.org/2026/next-gen-region-constraints.html), and more generally [Project Zero](https://goals.rust-lang.org/2026/roadmap-project-zero.html). It is a large priority of the Types Team to fix all type system unsoundnesses and to work towards there being a solid foundation to minimize the risk of unknown ones. > > This bug is a `P-high` issue and would have been `P-critical` regardless of whether people encountered it in the wild. The reason that it is "only `P-high`" is that it's 11 years old. A bug like this which has not been found during the last 11 years cannot actually be that easy to hit. > > Looking at the bug itself, it is also very likely that this unsoundness has not caused memory unsafety by accident. While it looks easy to trigger, to exploit this you need an intentionally malicious `Drop` implementation. > > ~ @lcnr --- In the following code: ```rust use std::sync::Mutex; static KEPT: Mutex<Vec<Box<dyn std::any::Any + Send>>> = Mutex::new(Vec::new()); struct Q<T: 'static + Send>(Option<T>); impl<T: 'static + Send> Drop fo

Comments (0)

No comments yet. Start the discussion.

Comment on this issue