Skip to content

Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata.#61630

Merged
CyrusNajmabadi merged 32 commits intodotnet:mainfrom
CyrusNajmabadi:solutionSync2
Jun 3, 2022
Merged

Update compiler to supported UnmanagedMemoryStream when creating ModuleMetadata.#61630
CyrusNajmabadi merged 32 commits intodotnet:mainfrom
CyrusNajmabadi:solutionSync2

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@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 requested a review from tmat June 1, 2022 15:38
@ghost ghost added the Area-IDE label Jun 1, 2022
@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
Copy Markdown
Contributor Author

This is ready for review.

@CyrusNajmabadi CyrusNajmabadi requested a review from sharwell June 1, 2022 17:46
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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
Copy Markdown
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.

6 participants