[release/5.0] [mono] Copy image data with AssemblyLoadContext.LoadFromStream#43593
Merged
lewing merged 1 commit intorelease/5.0from Oct 20, 2020
Merged
[release/5.0] [mono] Copy image data with AssemblyLoadContext.LoadFromStream#43593lewing merged 1 commit intorelease/5.0from
lewing merged 1 commit intorelease/5.0from
Conversation
We don't actually pin the byte array, so it must be copied or it can be overwritten once we run a GC on the LOH. Fixes #43402 Tested manually that it fixes the issue using the associated repro. This isn't really something that lends itself to a test, so that's the best I can do.
|
Tagging subscribers to this area: @CoffeeFlux |
Member
|
This codepath is used by the lazy assembly loading Blazor feature. |
Member
|
Approved in tactics. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #43592 to release/5.0
/cc @CoffeeFlux
Customer Impact
Fix was prompted by a customer bug report at #43402
This bug will affect anyone using AssemblyLoadContext.LoadFromStream on wasm with enough other data in the LOH to trigger a GC, so the potential for others to hit this seems high in real applications despite it not showing up in testing.
Testing
Manually validated against the attached repro. Problem goes away even after 10 iterations, when previously the corruption would be evident on the first.
Risk
Low. This is just a one-line change that ensure we copy the data locally into non-managed memory. The copying functionality is hit regularly multiple other places in the runtime in addition to being fairly simple, so it is unlikely to cause problems. In a .NET 5 context, this fix is wasm-specific.