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

Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata. #61630

Merged
merged 32 commits into from
Jun 3, 2022

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jun 1, 2022

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.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review June 1, 2022 16:51
@CyrusNajmabadi CyrusNajmabadi requested review from a team as code owners June 1, 2022 16:51
@CyrusNajmabadi
Copy link
Member Author

This is ready for review.

@CyrusNajmabadi CyrusNajmabadi requested a review from sharwell June 1, 2022 17:46
@CyrusNajmabadi
Copy link
Member Author

Definitely want @sharwell's eyes on this as well.

@CyrusNajmabadi CyrusNajmabadi changed the title Add the concept of a 'reference owner' to the metadata API to assist IDE scenarios Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata. Jun 1, 2022
@CyrusNajmabadi CyrusNajmabadi requested a review from AlekseyTs June 2, 2022 22:11
Copy link
Contributor

@AlekseyTs AlekseyTs left a 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)

@CyrusNajmabadi
Copy link
Member Author

@tmat for eyes and @dotnet/roslyn-compiler for another review plz :)

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Member

@jaredpar jaredpar left a 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

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge June 3, 2022 18:43
@CyrusNajmabadi CyrusNajmabadi merged commit 57147bc into dotnet:main Jun 3, 2022
@ghost ghost added this to the Next milestone Jun 3, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the solutionSync2 branch June 3, 2022 21:42
@RikkiGibson RikkiGibson modified the milestones: Next, 17.3 P3 Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants