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

[WIP] proc_macro: check non-interned handles for "leaks" between/after invocations. #63809

Closed
wants to merge 1 commit into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Aug 22, 2019

Inspired by #63804, this PR panics on some forms of proc_macro API misuse more eagerly (when a proc macro invocation finishes, as opposed to on the first use of a "leaked" handle).

However, it's unsure whether there are legitimate leaks of proc_macro "objects" in the wild, and @Centril suggested we try it out on crater first (check-only mode).

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 22, 2019
@eddyb
Copy link
Member Author

eddyb commented Aug 22, 2019

@bors try

@bors
Copy link
Contributor

bors commented Aug 22, 2019

⌛ Trying commit 1754dcd with merge d9c49acb7b15e0b6e1b797982100ad6c5d1424a2...

@bors
Copy link
Contributor

bors commented Aug 22, 2019

☀️ Try build successful - checks-azure
Build commit: d9c49acb7b15e0b6e1b797982100ad6c5d1424a2

@eddyb
Copy link
Member Author

eddyb commented Aug 23, 2019

@craterbot run mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-63809 created and queued.
🤖 Automatically detected try build d9c49acb7b15e0b6e1b797982100ad6c5d1424a2
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2019
bors added a commit that referenced this pull request Aug 23, 2019
[WIP] rustc_mir: disallow global mutable state in proc macros.

Along the lines of #63809, this PR attempts to get rid of the main (or only?) place `proc_macro` handles could be leaked to, *and* further disallow/discourage sharing (other) state between invocations.

The approach of banning (interior-)mutable `static`s was most recently mentioned in #63804 (comment), but it's likely been brought up several times, we just never tried it.
(Note that this is not foolproof: one would have to scan all dependencies for such `static`s, modulo `proc_macro`/`std`, and even then it's possible there would be a lot of false positives)

So this is mostly for a check-only crater run, to see what (if anything) breaks.
@pietroalbini
Copy link
Member

@craterbot crates=full

@craterbot
Copy link
Collaborator

📝 Configuration of the pr-63809 experiment changed.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@eddyb
Copy link
Member Author

eddyb commented Sep 12, 2019

@craterbot abort
(in favor of #64398)

@craterbot
Copy link
Collaborator

🗑️ Experiment pr-63809 deleted!

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Sep 12, 2019
@eddyb
Copy link
Member Author

eddyb commented Sep 19, 2019

I'm not sure we should land this, given that all 3 regressions in #64398 (comment) that can be directly attributed to this PR are "forgetful" leaks, not stashing proc_macro objects in thread-local storage.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 24, 2019

Maybe just make it a lint that ppl can silence?

@Alexendoo
Copy link
Member

Ping from triage, any updates? @eddyb

@eddyb
Copy link
Member Author

eddyb commented Oct 2, 2019

@oli-obk I'm not exactly sure how - at least it's on the server side of the proc-macro bridge - maybe I can add a method somewhere to report it and the default is eprintln! but rustc warns instead?

At least rustc would know the invocation and would be able to point to it, hmm.

@eddyb eddyb added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2019
@eddyb
Copy link
Member Author

eddyb commented Oct 2, 2019

Blocked on rust-lang/crater#461 to find the exact set of regressions.

@ecstatic-morse
Copy link
Contributor

@Mark-Simulacrum this was included in the crater run for #63831, which caused ~700 regressions. We want to be sure that that PR didn't mask any regressions in this one. I commented on the broken PR, but I meant for eddyb to trigger runs on all the others. I don't have crater perms, but could you trigger a run with:

@craterbot check crates=https://gist.githubusercontent.com/ecstatic-morse/ca6fe943de6937db635143472358d90d/raw/177739189815b3c52a7f69b494dbb91ea2d25e1d/gistfile1.txt

@craterbot
Copy link
Collaborator

🔒 Error: you're not allowed to interact with this bot.

🔑 If you are a member of the Rust team and need access, add yourself to the whitelist.
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

👌 Experiment pr-63809 created and queued.
🤖 Automatically detected try build d9c49acb7b15e0b6e1b797982100ad6c5d1424a2
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Oct 14, 2019
@Mark-Simulacrum
Copy link
Member

@craterbot p=1 Bumping priority since this is a short run

@craterbot
Copy link
Collaborator

🚨 Error: failed to parse the command

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Mark-Simulacrum
Copy link
Member

@craterbot p=1

Bumping priority since this is a short run

@craterbot
Copy link
Collaborator

📝 Configuration of the pr-63809 experiment changed.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-63809 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-63809 is completed!
📊 2 regressed and 0 fixed (656 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Oct 19, 2019
@eddyb
Copy link
Member Author

eddyb commented Oct 23, 2019

I doubt this is worth doing - these handles can't actually be (mis)used anyway.

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.

10 participants