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

Fix leaks from panics in destructors #125923

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

matthewjasper
Copy link
Contributor

Resurrects #78373.

This avoids the problem with #80949 by not unscheduling drops of function arguments until after the call (so they still get a drop terminator on the function unwind path).

Closes #47949

r? @lcnr

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 3, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 3, 2024

Some changes occurred in match lowering

cc @Nadrieril

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Jun 4, 2024

@bors try @rust-timer queue

r? @pnkfelix (as you've reviewed #78373 3 years ago :3) am looking through these changes myself but would like you to also take a look

@rust-timer

This comment has been minimized.

@rustbot rustbot assigned pnkfelix and unassigned lcnr Jun 4, 2024
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 4, 2024
@bors
Copy link
Contributor

bors commented Jun 4, 2024

⌛ Trying commit 28ac9be with merge 1c34390...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 4, 2024
Fix leaks from panics in destructors

Resurrects rust-lang#78373.

This avoids the problem with rust-lang#80949 by not unscheduling drops of function arguments until after the call (so they still get a drop terminator on the function unwind path).

Closes rust-lang#47949

r? `@lcnr`
@lcnr
Copy link
Contributor

lcnr commented Jun 4, 2024

Went through it and mostly understand this PR, am very much not comfortable enough to approve it myself 😅

Thanks @matthewjasper for picking this up again ❤️ really happy about this

@bors
Copy link
Contributor

bors commented Jun 4, 2024

☀️ Try build successful - checks-actions
Build commit: 1c34390 (1c343902c7b4004d4dcdeb3cc93fcdd886e21595)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1c34390): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [0.3%, 12.1%] 245
Regressions ❌
(secondary)
38.2% [0.3%, 723.1%] 156
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [0.3%, 12.1%] 245

Max RSS (memory usage)

Results (primary -1.8%, secondary -4.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.8% [0.8%, 5.9%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-8.7%, -0.9%] 36
Improvements ✅
(secondary)
-4.0% [-6.0%, -2.2%] 28
All ❌✅ (primary) -1.8% [-8.7%, 5.9%] 43

Cycles

Results (primary 2.4%, secondary 73.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [0.9%, 6.3%] 48
Regressions ❌
(secondary)
73.0% [1.2%, 281.7%] 33
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [0.9%, 6.3%] 48

Binary size

Results (primary 1.1%, secondary 1.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.0%, 4.9%] 136
Regressions ❌
(secondary)
1.3% [0.1%, 7.7%] 91
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [-0.1%, 4.9%] 138

Bootstrap: 673.596s -> 675.825s (0.33%)
Artifact size: 318.88 MiB -> 311.92 MiB (-2.19%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 4, 2024
@matthewjasper
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 14, 2024
@craterbot
Copy link
Collaborator

🎉 Experiment pr-125923 is completed!
📊 270 regressed and 1 fixed (474099 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. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 22, 2024
@matthewjasper
Copy link
Contributor Author

Looks like there's a bug somewhere (failures are ICEs)

@bors
Copy link
Contributor

bors commented Jun 24, 2024

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

Large arrays/tuples can have enough operands that removing items one at
a time is significantly slower than creating a hash set first.
When building the MIR we sometimes try to unschedule drops. In this we
assert that the drop has already been scheduled. Opaque types however
may be initialized with an expression kind that we know doesn't have a
type that needs to be dropped. To fix this we don't panic if we can't
find the drop of a variable with an opaque type.
@matthewjasper
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Jun 26, 2024

⌛ Trying commit 5c356c7 with merge 8585d8c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 26, 2024
Fix leaks from panics in destructors

Resurrects rust-lang#78373.

This avoids the problem with rust-lang#80949 by not unscheduling drops of function arguments until after the call (so they still get a drop terminator on the function unwind path).

Closes rust-lang#47949

r? `@lcnr`
@bors
Copy link
Contributor

bors commented Jun 26, 2024

☀️ Try build successful - checks-actions
Build commit: 8585d8c (8585d8c57bfa6d7d66340412e06b5611fa79cc61)

@rust-timer

This comment has been minimized.

@matthewjasper
Copy link
Contributor Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-125923-1 created and queued.
🤖 Automatically detected try build 8585d8c
🔍 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 Jun 26, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8585d8c): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.2%, 3.6%] 135
Regressions ❌
(secondary)
1.6% [0.2%, 7.1%] 48
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.9%, -0.3%] 5
All ❌✅ (primary) 1.1% [0.2%, 3.6%] 135

Max RSS (memory usage)

Results (primary 2.9%, secondary -0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.5% [1.3%, 8.2%] 11
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
-3.6% [-3.6%, -3.6%] 1
Improvements ✅
(secondary)
-5.5% [-5.5%, -5.5%] 1
All ❌✅ (primary) 2.9% [-3.6%, 8.2%] 12

Cycles

Results (primary 1.9%, secondary 3.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.9% [0.7%, 4.1%] 55
Regressions ❌
(secondary)
4.2% [1.1%, 7.4%] 15
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.4% [-4.4%, -4.4%] 1
All ❌✅ (primary) 1.9% [0.7%, 4.1%] 55

Binary size

Results (primary 1.1%, secondary 1.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.0%, 4.9%] 138
Regressions ❌
(secondary)
1.3% [0.1%, 7.7%] 91
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [-0.0%, 4.9%] 139

Bootstrap: 693.722s -> 697.127s (0.49%)
Artifact size: 326.71 MiB -> 327.43 MiB (0.22%)

@craterbot
Copy link
Collaborator

🚧 Experiment pr-125923-1 is now running

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

@pnkfelix
Copy link
Member

pnkfelix commented Jun 28, 2024

Finally got around to making a pernos.co run with and without this PR in place, to aid me to inpsect a fine-grained trace of its behavior.

@craterbot
Copy link
Collaborator

🎉 Experiment pr-125923-1 is completed!
📊 19 regressed and 8 fixed (475963 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 Jun 30, 2024
@pnkfelix
Copy link
Member

pnkfelix commented Jul 5, 2024

I still haven't had a chance to give this a proper review, and I am about to go on vacation for a week.

So I'm going to re-roll the review. If it doesn't get reviewed within ten days, feel free to re-assign it to me again.

r? compiler-team

@rustbot rustbot assigned michaelwoerister and unassigned pnkfelix Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panics in destructors can cause the return value to be leaked
9 participants