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

[release/6.0] [iOS][Android] Fix crash in Exception.CaptureDispatchState #71171

Merged
merged 4 commits into from
Jul 12, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jun 22, 2022

Backport of #70970 to release/6.0

/cc @steveisok

Customer Impact

There exists a race condition in mono's implementation of Exception.CaptureDispatchState that can cause a crash when an exception is re-thrown from an await from multiple observers. The crash happens when Exception.RestoreDispatchState is called at the same time Exception.CaptureDispatchState is and an Array.Copy fails due to an internal member length change.

This is impacting a customer that is trying to move over to MAUI, but can't due to this issue.

Testing

Manual testing of a customer provided reproduction

Risk

Low - the change captures the shared state in a local variable so that Exception.CaptureDispatchState can do its job

IMPORTANT: If this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

Steve Pfister added 3 commits June 22, 2022 22:31
There is a crash in `Exception.CaptureDispatchState` when called from one thread at the same time another calls into `Exception.RestoreDispatchState`. The
reason for the crash is due to the way we do not update `foreignExceptionFrames` in a thread-safe way.  `foreignExceptionFrames` is used in both methods and can crash when the size changes before the array is copied.

The fix is to lock when reading from and writing to `foreignExceptionFrames`.

Fixes #70081
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@marek-safar marek-safar added the Servicing-consider Issue for next servicing release review label Jun 23, 2022
@marek-safar marek-safar added this to the 6.0.x milestone Jun 23, 2022
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jun 23, 2022
@leecow leecow modified the milestones: 6.0.x, 6.0.8 Jun 23, 2022
@lewing lewing merged commit feb1697 into release/6.0 Jul 12, 2022
@lewing lewing deleted the backport/pr-70970-to-release/6.0 branch July 12, 2022 18:00
@ghost ghost locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants