Double Drop with #![deny(rust_2024_compatibility)] #134482
Labels
A-edition-2024
Area: The 2024 edition
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
L-tail_expr_drop_order
Lint: tail_expr_drop_order
P-critical
Critical priority
regression-from-stable-to-beta
Performance or correctness regression from stable to beta.
S-has-bisection
Status: a bisection has been found for this issue
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I had a custom Rc that was doubly freeing memory because Drop was being called more times than it should.
After a little bit of testing I think this is a small enough Minimal-Reproducible-Example:
playground
I expected to see this happen: Drop is called twice.
Instead, this happened: Drop is called 3 times.
Notes
Result<String, ()>
It seems that it happens as long as it is an enum in which one arm has a non-
Copy
type.So it also happens if the return type is
--release
flagMeta
rustc --version --verbose
:Backtrace
Reduced stderr from the playground:
The text was updated successfully, but these errors were encountered: