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

Best practices for bug fixes in the compiler #1589

Merged
merged 3 commits into from
Aug 18, 2016

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Apr 22, 2016

Defines a "best practices" procedure for making bug fixes or soundness corrections in the compiler that can cause existing code to stop compiling.

Rendered view.

@nikomatsakis nikomatsakis added the T-compiler Relevant to the compiler team, which will review and decide on the RFC. label Apr 22, 2016
@nikomatsakis nikomatsakis self-assigned this Apr 22, 2016
@nikomatsakis
Copy link
Contributor Author

cc @rust-lang/compiler

@sgrif
Copy link
Contributor

sgrif commented Apr 23, 2016

One case that this leaves unaddressed is if a security vulnerability were to occur that required a breaking change to address. Presumably in that case there would not be a forwards compatibility warning?

@nagisa
Copy link
Member

nagisa commented Apr 23, 2016

@sgrif what is a security vulnerability in a compiler or a language? I can’t think of any potential issues which could be related to “security” but aren’t related to any of the soundness bugs.

@jethrogb
Copy link
Contributor

jethrogb commented Apr 23, 2016

@nagisa e.g. a miscompilation that almost always results in an exploitable buffer overflow. Like rust-lang/rust#31234 but worse.

@nagisa
Copy link
Member

nagisa commented Apr 23, 2016

@jethrogb I’d classify any “miscompilation” as a “Compiler bug”.


- **Soundness changes:** Fixes to holes uncovered in the type system.
- **Compiler bugs:** Places where the compiler is not implementing the
specified semantics found in an RFC or lang-team decision.
Copy link
Member

Choose a reason for hiding this comment

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

We do not have an RFC for the whole language as it was before RFC process was introduced. Perhaps this should also include things like the rust reference?

Copy link
Contributor Author

@nikomatsakis nikomatsakis Apr 27, 2016

Choose a reason for hiding this comment

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

@nagisa #1122 specifically addressed this point, under the section on "underspecified language semantics". I do not consider the rust reference to be normative (though I have done sweeps at various points to try and find inaccuracies and so forth). I would say it's comparable to the official rust grammar -- a work in progress.

@jethrogb
Copy link
Contributor

jethrogb commented Apr 23, 2016

I’d classify any “miscompilation” as a “Compiler bug”.

I can agree with that, but that still doesn't answer @sgrif's question. There are many different soundness bugs some of which might be more serious than others. I'm thinking an edge case in the type system that almost no one is encountering vs. failing to emit bounds checks.

@sgrif
Copy link
Contributor

sgrif commented Apr 23, 2016

It doesn't matter if it's a "Compiler bug" or not. My point is that this RFC declares that all cases should have a forwards compatibility warning, when there are classes that probably shouldn't. I was simply pointing out that I think this should likely be addressed.

@jethrogb
Copy link
Contributor

jethrogb commented Apr 23, 2016

I whole-heartedly agree. What's missing—not necessarily in this RFC, but in the current release process in general—is the ability to do bugfix-only point releases.¹ We have been getting away with not doing those so far but it's completely possible that at some point in the future there will be a huge bug (security-related or not) that might need immediate fixing in stable. A seperate question—one we might address here—is, what if the fix for that huge bug is not backwards-compatible?

¹ RFC 507: "Provisions for stable point releases will be made at a future time."

@nikomatsakis
Copy link
Contributor Author

@sgrif

One case that this leaves unaddressed is if a security vulnerability were to occur that required a breaking change to address. Presumably in that case there would not be a forwards compatibility warning?

Interesting point. I can add some text saying that we may want to consider foregoing a warning period in particularly dire cases. That said, I am not sure what such a case would be just now. For example, we generally try to patch soundness holes in the type system with warnings first, because in practice most code that is relying on them is not in fact going to crash. (Note also that users can -- and probably should -- add things like #[deny(forwards_incompatible)] to get stricter checks locally.) The example of foregoing bounds checks failures is something I imagine we would simply fix, since fixing it will not cause compilation errors (in general there is no good way to issue a "warning period" for pure runtime patches). Nonetheless, never say never: I'm sure we'll eventually encounter a scenario like the one you describe.

@nikomatsakis
Copy link
Contributor Author

I wrote this in my last comment:

I can add some text saying that we may want to consider foregoing a warning period in particularly dire cases.

But I just want to clarify one thing. The RFC doesn't say you must issue warnings even now. It just says that if you plan to forego them, there are had better be a good reason (for example, issuing warnings is infeasible).

@nikomatsakis
Copy link
Contributor Author

I've been contemplating a loosening of this policy. Basically I think we should convert the "infeasible" clause into a sort of exemption for PRs with particularly small impact. Specifically:

"If a crater run reveals fewer than 10 total affected projects (not root errors), we can move straight to an error. In such cases, we should still make the "breaking change" page as before, and we should always ensure that the error directs users to this page. In other words, everything should be the same except that they are getting an error, and not a warning. Moreover, we should submit PRs to the affected projects (ideally before the PR implementing the change lands in rustc). If more than 10 crates are affected, warnings are mandatory -- if implementing warnings is not feasible, then we have to make an aggressive strategy of migrating crates before we land the change so as to lower the number of affected crates."

That said, I hope that we would prefer warnings even when very few crates are affected. I want us to make a point of pride on ensuring that all users have the best transition experience possible -- and warnings are strictly better than errors. Moreover, crater runs remain a very imperfect measurement of affected change. (Note though that we are now also gating on certain key crates, such as cargo or winapi, so those crates will never break no matter what -- if they would be affected, then they must be fixed first.)

But at the same time I want to balance the total engineering effort and make sure that we can still make forward progress without getting stuck implementing a lot of warning scaffolding for changes with little real-world impact.

@nikomatsakis
Copy link
Contributor Author

OK, I have finally adjusted the wording as I wanted to do. Nominating for FCP.

@pnkfelix
Copy link
Member

This RFC is entering its 🔔 final comment period 🔔

@pnkfelix pnkfelix added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed I-nominated labels Jul 21, 2016

- Eliminate the tracking issue.
- Change the stabilization schedule.
-
Copy link
Member

Choose a reason for hiding this comment

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

This - sign here messes up formatting.

@nikomatsakis
Copy link
Contributor Author

Huzzah! The @rust-lang/compiler team has decided to accept this RFC. Actually, we decided a long time ago, but I kept forgetting to merge. Done!

@nikomatsakis nikomatsakis merged commit d795e41 into rust-lang:master Aug 18, 2016
@Centril Centril added A-governance Proposals relating to how Rust is governed. A-best-practices Proposals relating to best practices. labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-best-practices Proposals relating to best practices. A-governance Proposals relating to how Rust is governed. final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-compiler Relevant to the compiler team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants