Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Partial properties: duplicate membersByName before merging accessors #74969

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

cston
Copy link
Member

@cston cston commented Aug 31, 2024

Duplicate membersByName dictionary before modifying in mergeAccessors if the dictionary is cached.

Note, the potential race condition is speculative. I'm not aware of a reported issue, and I have not been able to create a test that hits an issue here.

Relates to test plan #73090

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 31, 2024
membersByName = new Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>(membersByName, ReadOnlyMemoryOfCharComparer.Instance);
}

DuplicateMembersByNameIfCached(ref membersByName);
Copy link
Member Author

@cston cston Aug 31, 2024

Choose a reason for hiding this comment

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

Previously, membersByName was modified in mergeAccessors before duplicating.

@cston cston marked this pull request as ready for review August 31, 2024 21:04
@cston cston requested a review from a team as a code owner August 31, 2024 21:04
@cston cston requested a review from RikkiGibson August 31, 2024 21:04
@RikkiGibson RikkiGibson self-assigned this Sep 3, 2024
membersByName[name] = FixPartialMember(membersByName[name], prevProperty, currentProperty);
}

void mergeAccessors(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, ReadOnlyMemory<char> name, SourcePropertyAccessorSymbol? currentAccessor, SourcePropertyAccessorSymbol? prevAccessor)
void mergeAccessors(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, SourcePropertyAccessorSymbol? currentAccessor, SourcePropertyAccessorSymbol? prevAccessor)
Copy link
Contributor

Choose a reason for hiding this comment

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

It also seems like this function could take membersByName by value instead.

@cston cston merged commit 4619ed7 into dotnet:main Sep 3, 2024
24 checks passed
@cston cston deleted the mergeAccessors branch September 3, 2024 17:37
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 3, 2024
@akhera99 akhera99 modified the milestones: Next, 17.12 P3 Sep 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area-Compilers Feature - Partial Properties untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants