Skip to content

fix crash in async-drop and async-gen (fix-#161101) - #161190

Open
im-lunex wants to merge 4 commits into
rust-lang:mainfrom
im-lunex:fix_#161101
Open

fix crash in async-drop and async-gen (fix-#161101)#161190
im-lunex wants to merge 4 commits into
rust-lang:mainfrom
im-lunex:fix_#161101

Conversation

@im-lunex

@im-lunex im-lunex commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

handle AsyncGenPending constants in FixReturnPendingVisitor rewrite AsyncGenPending constant uses to Poll::<()>::Pending in FutureDropPoll shims, matching the existing aggregate path

also added a regression test for #161101.

issue reproduce - https://godbolt.org/z/d1zb4j974

@rustbot

rustbot commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Aug 16, 2026
@rustbot

rustbot commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir, mir-opt
  • compiler, mir, mir-opt expanded to 75 candidates
  • Random selection from 19 candidates

if place.local != RETURN_PLACE {
return;
}

@oli-obk oli-obk Aug 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more remaining accidental edit

View changes since the review

@im-lunex im-lunex Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for reviewing 🫡

} else if let Rvalue::Use(Operand::Constant(constant), _) = rvalue {
if let Some(async_gen_pending_def_id) = self.tcx.lang_items().async_gen_pending()
&& let Const::Unevaluated(unevaluated, _) = constant.const_
&& unevaluated.def == async_gen_pending_def_id

@oli-obk oli-obk Aug 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does this happen? Can we somehow either always cause this to happen or always take the above path by ensuring this never happens?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this fixes the case when the compiler uses the AsyncGenPending lang item for async-gen suspension points. and i see you are saying the approach to make the compiler never use AsyncGenPending(if im not wrong) that kind of an experimental fix, cause we have to touch places where AsyncGenPending is generated... this part of the compiler is a bit sensitive that can demand larger changes and possibly cause performance impact too.. soo i think this approach is by far the simplest fix

@oli-obk oli-obk assigned oli-obk and unassigned TaKO8Ki Aug 17, 2026
@oli-obk oli-obk 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants