Replies: 1 comment 4 replies
-
It's not quite clear about the concepts here. Async/await has little relationship with inlining. Instead, await'd method executes in a total different stack. If you observe the exception in VS debugger, you can see VS concatenates the stack traces for you. The real stack is separated by awaits.
It depends on the implementation of
Right. The stack stitching is done by debugger that understands async.
The nature of BAsync would only affect stack trace under BAsync. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have some understanding how stack traces work and how it might interact with async/await, scheduling continuations on thread pool, inlining, and Task unobserved exceptions, but I'm not exactly sure how it all works together.
So imagine a scenario. There's a task kicked off that is made of an async method AAsync(...) the result of which is never awaited, i.e. any exception is unobserved.
As part of this async method another async method is called, let's call it BAsync(...), a sync framework method, let's say .WaitAsync(....) is called. It's in a context where inlining seems plausible. The internals of the WaitAsync method throws an exceptions (let's say NRE, due to it not being thread safe).
Let's say we have an handler on unobserved exceptions:
That logs the exception. Now let's say the stack trace of the logged exceptions contains only BAsync(...). Is it plausible? I.e. it not containing WaitAsync due to inlining?
What about ASync(...). If the WaitAsync call is after an await, i.e. it's in an continuation part AAsync won't be on real stack and IIRC there's no automatic stack stitching, is that correct?
Would that be different if BAsync was, instead of as part of explicitley started Task, triggered as callback for cancellation token?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions