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
{{ message }}
Repository navigation
Inconsistent evaluation order for assignment operations #27868
A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityT-langRelevant to the language teamfixed-by-NLLBugs fixed, but only when NLL is enabled.
Currently, the borrow checker thinks that the RHS of += is evaluated before the LHS. trans thinks that the LHS is evaluated before the RHS. The disagreement leads to bad results.
fnmain(){let x = Box::new(0);letmut y = 0;*{drop(x);&mut y } += *x;assert_eq!(y,0);}
So the internals thread says this: "before MIR, we were actually quite inconsistent here, in that borrowck and trans disagreed on some of the particulars. MIR eliminated that inconsistency, but there are still some matters that we should try to resolve -- and quick!" If that's the case, then this should be closed. @nikomatsakis Is this the case?
NLL (migrate mode) is enabled in all editions as of PR #59114.
The only policy question is that, under migrate mode, we only emit a warning on this (unsound) test case. Therefore, I am not 100% sure whether we should close this until that warning has been turned into a hard-error under our (still in development) future-compatibility lint policy.
A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityT-langRelevant to the language teamfixed-by-NLLBugs fixed, but only when NLL is enabled.
Activity
nrc commentedon Nov 19, 2015
triage: P-medium
Also fixed by MIR (almost a dup of #28160, but not quite)/
nikomatsakis commentedon Oct 21, 2016
See this internals thread: https://internals.rust-lang.org/t/settling-execution-order-for/4253
Mark-Simulacrum commentedon May 6, 2017
So the internals thread says this: "before MIR, we were actually quite inconsistent here, in that borrowck and trans disagreed on some of the particulars. MIR eliminated that inconsistency, but there are still some matters that we should try to resolve -- and quick!" If that's the case, then this should be closed. @nikomatsakis Is this the case?
nikomatsakis commentedon May 8, 2017
Well, we're not yet running the borrowck on MIR, so I'm not sure.
nikomatsakis commentedon May 8, 2017
But certainly the example seems to work ok now.
RalfJung commentedon Jun 15, 2017
Assignment operators are still wrong, which can lead to use-after-free:
Prints
Credit to @xfix for bringing this up in rust-lang/rfcs#2025 (comment), I just weaponized it.
14 remaining items
pnkfelix commentedon Apr 29, 2019
NLL (migrate mode) is enabled in all editions as of PR #59114.
The only policy question is that, under migrate mode, we only emit a warning on this (unsound) test case. Therefore, I am not 100% sure whether we should close this until that warning has been turned into a hard-error under our (still in development) future-compatibility lint policy.