tail calls: fix copying non-scalar arguments to callee#150473
tail calls: fix copying non-scalar arguments to callee#150473RalfJung wants to merge 1 commit intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
3604bf5 to
0d2a400
Compare
|
☔ The latest upstream changes (presumably #150565) made this pull request unmergeable. Please resolve the merge conflicts. |
0d2a400 to
1bccfe8
Compare
This comment has been minimized.
This comment has been minimized.
|
I looked into this some at #144855 (comment). In summary, I believe that a tail call that uses an argument that is Supporting |
1bccfe8 to
b3bdf0f
Compare
This comment has been minimized.
This comment has been minimized.
|
Thanks, I had not seen that issue! What a mess. Whatever rules we come up with should be portable to all targets... Anyway, that's mostly orthogonal to what we do in the interpreter. Fixing the order in which we copy arguments and deallocate the old locals still makes sense IMO. |
|
@WaffleLapkin just a friendly ping -- are you okay with reviewing this or should I find another reviewer? |
This comment has been minimized.
This comment has been minimized.
| help: ALLOC was deallocated here: | ||
| --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC | ||
| | | ||
| LL | f(std::ptr::null()); | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
| LL | let _val = unsafe { *x }; | ||
| | ^^^^ |
There was a problem hiding this comment.
arguably neither the old nor the new diagnostic is correct...
There was a problem hiding this comment.
Fair, though the new one is really strange... good point.
The old one kind of makes sense -- doing a tail call deallocates the locals of the old stack frame. (Though it'd be better to point at the become.)
There was a problem hiding this comment.
Oh wait, it used to point into main? Yeah that's nonsense.^^
b3bdf0f to
ad5108e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=WaffleLapkin |
Alternative to #144933: when invoking a tail call with a non-scalar argument, we need to delay freeing the caller's local variables until after the callee is initialized, so that we can copy things from the caller to the callee.
Fixes #144820... but as the FIXMEs in the code show, it's not clear to me whether these are the right semantics.
r? @WaffleLapkin