-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata. #61630
Conversation
src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.SkeletonReferenceSet.cs
Outdated
Show resolved
Hide resolved
This is ready for review. |
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
Definitely want @sharwell's eyes on this as well. |
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/MetadataReference/ModuleMetadata.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes under Compilers LGTM (commit 20)
@tmat for eyes and @dotnet/roslyn-compiler for another review plz :) |
src/Compilers/Core/CodeAnalysisTest/MetadataReferences/ModuleMetadataTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed compiler side of changes
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.