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

debuginfo: identify awaitee (via special name or other solution) #95521

Open
pnkfelix opened this issue Mar 31, 2022 · 4 comments
Open

debuginfo: identify awaitee (via special name or other solution) #95521

pnkfelix opened this issue Mar 31, 2022 · 4 comments
Assignees
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting.

Comments

@pnkfelix
Copy link
Member

Spawned off of #73524 (comment)

For debugging async crash dumps (and async stack traces in general, I think), the debugger needs to identify the awaitee field in some manner.

There have been various suggestions here, such as changing the await desugaring to move the awaitee to a temporary with a special name like $awaitee that one cannot write in normal rust code. But there may be "gotchas" here; @tmandry noted that "for combinators and such you'll have to do something special".

@pnkfelix
Copy link
Member Author

another suggestion: "the other thing you can do is put debuginfo metadata on the generator variant associated with that await point"

@pnkfelix pnkfelix self-assigned this Apr 14, 2022
@csmoe csmoe added the A-async-await Area: Async & Await label Apr 14, 2022
@eholk
Copy link
Contributor

eholk commented Apr 25, 2022

@michaelwoerister did some work on this with #95011, although it doesn't look like that one covers combinators like select! and join!.

@rustbot label +AsyncAwait-Triaged

@rustbot rustbot added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Apr 25, 2022
@eholk
Copy link
Contributor

eholk commented Apr 25, 2022

We talked about the combinator issue some more in the triage meeting. It seems like we don't have a good sense yet of how well combinators currently work (the answer is probably "not well" although some simpler ones might "just work™"), and we also don't really know what the expectations are. We should clarify these things and then work out a design for handling combinators.

@michaelwoerister
Copy link
Member

Here are my thoughts on the topic:

For logical async stack traces (i.e. stack traces of async fns that are currently suspended), we want to be able to identify what a particular fn is awaiting. We do that by looking at the suspended state of the fn. This state is basically an enum with a variant for each state the fn can be in, and each variant has fields for local variables that are kept alive across suspension points. #95011 made sure that the local variable generated for simple .await expressions always gets the name __awaitee. So, in the debugger, if we find a field called __awaitee in the suspended state of an async fn, we know that that is the thing being awaited.

However, one can also awaite (multiple) things via join!() and select!(), and those are unlikely to generate something that can reliably be identified and reconstructed in a debugger. There are even multiple implementations of those macros (e.g. in future-rs and tokio).

So, one possible approach would be to always wrap the state being captured when an fn is suspended during a join!() or select!() inside of a well-known type (possibly defined in the standard library), and maybe also make the macros generate a well-known name for the binding. The goal is, again, that if we look at the suspended async state in the debugger, we want to reliably be able to tell if something was generated by a join!() or select!() and what the arguments of it are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting.
Projects
None yet
Development

No branches or pull requests

5 participants