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

No unleashing of legal code #71748

Closed
wants to merge 2 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented May 1, 2020

r? @RalfJung @ecstatic-morse

We have some tests (that are now not using unleash anymore) that I believe used unleash to guard against any changes to static checks suddenly causing code to be evaluated and then triggering dynamic checks.

This PR was created after discussion in #71631 (comment)

// If all skipped operations could also be turned on by a feature gate, then we want
// to emit an error. So when we see a non-feature gate operation being skipped, disable
// that error reporting.
if O::feature_gate().is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

I think the point of the flag is to make the static checker shut up. So, whether or not something requires a feature gate in the static checker should not have any influence on what happens.

So, I am not a big fan of this proposal.

@@ -1,4 +1,3 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![allow(const_err)]

// Make sure we cannot mutate globals.
Copy link
Member

Choose a reason for hiding this comment

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

This test should now be moved to a different directory.

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait... no, this test is fine.

Copy link
Member

Choose a reason for hiding this comment

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

This is very similar to #71748 (comment) -- the point of the test is to make sure the dynamic checks can catch this error no matter what the static checks are doing. But after removing the flag we don't know any more if that is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea this is already hitting dynamic checks because our static checks can only detect mutations of statics opportunistically. While we could have a static check right now, with mutable references on the horizon that check would just stop working again.

@@ -1,5 +1,4 @@
// run-pass
// compile-flags: -Zunleash-the-miri-inside-of-you
Copy link
Member

Choose a reason for hiding this comment

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

This test should be moved to a different directory.

@@ -1,5 +1,4 @@
// revisions: default unleash
//[unleash]compile-flags: -Zunleash-the-miri-inside-of-you
// revisions: default
Copy link
Member

Choose a reason for hiding this comment

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

This basically reverts #71604. I specifically wrote that PR to make sure that the dynamic checks are able to catch this problem, even if the static checks might one day evolve to also be able to handle it (e.g. via #71526). So, this change potentially reduces future test coverage for the dynamic checks, which is not great.

That's why I think "-Zmiri-unleash will make compilation fail" is a better safety net than your proposal. It catches read_from_static.rs (which we all agree should not use the flag), but permits this test here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, this issue is why I left a longer comment in the PR's main comment, even though I misexplained what is going on exactly in the opposite way.

@RalfJung RalfJung added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2020
@RalfJung
Copy link
Member

RalfJung commented May 1, 2020

So taking a step back, I see the flag has been used for two different purposes:

  • To shut up the static checker so that we can better test the dynamic checker (whose error paths are otherwise often unreachable, modulo static checker bugs). That's what I thought it was exclusively meant for. This purpose is hindered by your proposal.
  • In caller-location-fnptr-rt-ctfe-equiv.rs, to test some const-code that doesn't even have feature gates. Are there more examples of this?

I don't think the flag should serve the second purpose, and we should come up with something else to do with those tests (e.g., introduce an incomplete experimental feature flag for const fn pointers).

@ecstatic-morse
Copy link
Contributor

I think it's fine to have -Zunleash "shut up the static checker" for either purpose. Presumably we want to test that the CTFE engine returns the correct result even for code that would never pass the static checker. I suppose you could argue that these tests should live in the miri repo instead?

@oli-obk
Copy link
Contributor Author

oli-obk commented May 2, 2020

I agree that this PR doesn't fix the situation and has no way forward to doing so

@oli-obk oli-obk closed this May 2, 2020
@oli-obk oli-obk deleted the no_unleashing_of_legal_code branch March 16, 2021 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants