Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak the way we protect in-place function arguments in interpreters #122076

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

WaffleLapkin
Copy link
Member

Use MPlaceTy instead of PlaceTy in FnArg and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be").

This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame).

r? @RalfJung
cc @oli-obk
see #121273 (comment)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 6, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2024

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@WaffleLapkin
Copy link
Member Author

So the good news: rebasing #113128 (487678d) unto this fixes the issues I was having! The bad news is that this breaks some tests :(


if let Either::Left(destination) = destination.as_mplace_or_local() {
// Protect return place for in-place return value passing.
M::protect_in_place_function_argument(self, &destination)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes cleaner once #121985 lands.

@WaffleLapkin
Copy link
Member Author

WaffleLapkin commented Mar 6, 2024

Ok, so what fails are the two tests (tests/fail/function_calls/arg_inplace_observe_after.rs, tests/fail/function_calls/return_pointer_aliasing2.rs) which check that a local moved to an argument or used as a return place can't be read from. @RalfJung do you have ideas what to do here?

The solution seems to be what is described in #122076 (comment)

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! r=me with nits fixed.

@bors
Copy link
Contributor

bors commented Mar 7, 2024

☔ The latest upstream changes (presumably #121985) made this pull request unmergeable. Please resolve the merge conflicts.

@WaffleLapkin
Copy link
Member Author

@bors r=@RalfJung

@bors
Copy link
Contributor

bors commented Mar 7, 2024

📌 Commit 5c5f496 has been approved by RalfJung

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#118623 (Improve std::fs::read_to_string example)
 - rust-lang#119365 (Add asm goto support to `asm!`)
 - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts)
 - rust-lang#121885 (Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type.)
 - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes)
 - rust-lang#122099 (Add  `#[inline]` to `BTreeMap::new` constructor)
 - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#118623 (Improve std::fs::read_to_string example)
 - rust-lang#119365 (Add asm goto support to `asm!`)
 - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts)
 - rust-lang#121832 (Add new Tier-3 target: `loongarch64-unknown-linux-musl`)
 - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes)
 - rust-lang#122099 (Add  `#[inline]` to `BTreeMap::new` constructor)
 - rust-lang#122103 (Make TAITs and ATPITs capture late-bound lifetimes in scope)
 - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Mar 8, 2024

☔ The latest upstream changes (presumably #122182) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 8, 2024
Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an
earlier step ("Locals that don't have their address taken are as protected as
they can ever be").

This seems to be crucial for tail call support (as they can't refer to caller's
locals which are killed when replacing the stack frame).
@WaffleLapkin
Copy link
Member Author

@bors r=@RalfJung

@bors
Copy link
Contributor

bors commented Mar 8, 2024

📌 Commit a984322 has been approved by RalfJung

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 8, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121025 (add known-bug tests for derive failure to detect packed repr)
 - rust-lang#121194 (Refactor pre-getopts command line argument handling)
 - rust-lang#121563 (Use `ControlFlow` in visitors.)
 - rust-lang#122173 (Don't ICE in CTFE if raw/fn-ptr types differ)
 - rust-lang#122175 (Bless tidy issues order)
 - rust-lang#122179 (rustc: Fix typo)
 - rust-lang#122181 (Fix crash in internal late lint checking)
 - rust-lang#122183 (interpret: update comment about read_discriminant on uninhabited variants)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)
 - rust-lang#122132 (Diagnostic renaming 3)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121025 (add known-bug tests for derive failure to detect packed repr)
 - rust-lang#121194 (Refactor pre-getopts command line argument handling)
 - rust-lang#121563 (Use `ControlFlow` in visitors.)
 - rust-lang#122173 (Don't ICE in CTFE if raw/fn-ptr types differ)
 - rust-lang#122175 (Bless tidy issues order)
 - rust-lang#122179 (rustc: Fix typo)
 - rust-lang#122181 (Fix crash in internal late lint checking)
 - rust-lang#122183 (interpret: update comment about read_discriminant on uninhabited variants)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)
 - rust-lang#122132 (Diagnostic renaming 3)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#121201 (align_offset, align_to: no longer allow implementations to spuriously fail to align)
 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)
 - rust-lang#122100 (Better comment for implicit captures in RPITIT)
 - rust-lang#122157 (Add the new description field to Target::to_json, and add descriptions for some MSVC targets)
 - rust-lang#122164 (Fix misaligned loads when loading UEFI arg pointers)
 - rust-lang#122171 (Add some new solver tests)
 - rust-lang#122172 (Don't ICE if we collect no RPITITs unless there are no unification errors)
 - rust-lang#122197 (inspect formatter: add braces)
 - rust-lang#122198 (Remove handling for previously dropped LLVM version)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2c3ca09 into rust-lang:master Mar 8, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
Rollup merge of rust-lang#122076 - WaffleLapkin:mplace-args, r=RalfJung

Tweak the way we protect in-place function arguments in interpreters

Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be").

This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame).

r? `@RalfJung`
cc `@oli-obk`
see rust-lang#121273 (comment)
@WaffleLapkin WaffleLapkin deleted the mplace-args branch March 9, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants