Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata.#61630
Merged
CyrusNajmabadi merged 32 commits intodotnet:mainfrom Jun 3, 2022
Merged
Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata.#61630CyrusNajmabadi merged 32 commits intodotnet:mainfrom
CyrusNajmabadi merged 32 commits intodotnet:mainfrom
Conversation
CyrusNajmabadi
commented
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
commented
Jun 1, 2022
src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.SkeletonReferenceSet.cs
Outdated
Show resolved
Hide resolved
Contributor
Author
|
This is ready for review. |
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
Contributor
Author
|
Definitely want @sharwell's eyes on this as well. |
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
tmat
reviewed
Jun 1, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
AlekseyTs
approved these changes
Jun 3, 2022
Contributor
AlekseyTs
left a comment
There was a problem hiding this comment.
Changes under Compilers LGTM (commit 20)
Contributor
Author
|
@tmat for eyes and @dotnet/roslyn-compiler for another review plz :) |
tmat
reviewed
Jun 3, 2022
src/Compilers/Core/CodeAnalysisTest/MetadataReferences/ModuleMetadataTests.cs
Outdated
Show resolved
Hide resolved
jaredpar
approved these changes
Jun 3, 2022
Member
jaredpar
left a comment
There was a problem hiding this comment.
Reviewed compiler side of changes
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
commented
Jun 3, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
CyrusNajmabadi
commented
Jun 3, 2022
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Followup to #61608.
The IDE generates PEReferences that point to an AssemblyMetadata object whose backing data is a raw pointer in memory. As long as the assemblymetadata is alive, the backing object that owns that memory must not be GC'ed (or we will get corruption and crashes as teh AssemblyMetadata tries to read from reclaimed memory.
Currently, the IDE supports this by using CWTs to keep things alive. However, as @tmat points out, a much cleaner approach would be to just allow hte metadata object itself to root the object that owns the memory. That way as long as the metadata object is alive, the memory can't be reclaimed. This PR adds taht capability to the low level API and shows how that simplifies things at the IDE level.