Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@monojenkins
Copy link
Contributor

In task.GetAwaiter().OnCompleted(action) if action throws, the TaskContinuation.RunOrScheduleAction method will catch the exception and then call RuntimeAugments.ReportUnhandledException. We must not simply throw the exception again - in that case we will lose all the frames leading up to the catch in RunOrScheduleAction. Instead use ExceptionDispatchInfo to capture the original throw.

Addresses #19166

Backport of #19168.

/cc @lambdageek

…ontinuation

In `task.GetAwaiter().OnCompleted(action)` if `action` throws, the
`TaskContinuation.RunOrScheduleAction method will catch the exception and then
call `RuntimeAugments.ReportUnhandledException`.  We must not simply throw the
exception again - in that case we will lose all the frames leading up to the
`catch` in `RunOrScheduleAction`.  Instead use ExceptionDispatchInfo to
caputure the original throw.

Addresses mono#19166
For annoying reasons we can't run this as a simple NUnit test because the
exception is unhandled on some arbitrary threadpool worker thread, and those
don't show up within an NUnit setup.

Additionally because the unhandled exception in the root domain would normally
terminate the application, we need to run this in a new appdomain.
@lambdageek lambdageek merged commit f2379f2 into mono:2019-12 Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants