Fix ReferenceTrackerHost fixed-address storage#129669
Open
Copilot wants to merge 3 commits into
Open
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix FixedAddressValueType handling in CoreCLR implementation
Fix ReferenceTrackerHost fixed-address storage
Jun 21, 2026
jkotas
reviewed
Jun 21, 2026
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Contributor
Author
jkotas
approved these changes
Jun 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts how ReferenceTrackerHost stores the global COM host “this” pointer so that the fixed-address storage is applied to a non-primitive value type while preserving the native layout expected by IReferenceTrackerManager.SetReferenceTrackerHost.
Changes:
- Replaced the fixed-address static
IntPtrused as the host object with a single-field value-type instance holding the vtable pointer. - Updated
SetReferenceTrackerHostto pass the address of that fixed instance to the nativeSetReferenceTrackerHostcall.
AaronRobinsonMSFT
approved these changes
Jun 21, 2026
Contributor
|
(Btw, you can also just use |
Member
|
ValueTuple has large set of dependencies. It comes with code bloat risk. Avoiding it saves you from having to worry about it in code that's likely included in minimal apps that we track naot binary sizes for. |
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.
ReferenceTrackerHoststoreds_globalHostServicesas anIntPtrannotated with[FixedAddressValueType], but that attribute does not apply to primitive value types. This change avoids relying on that unsupported combination while keeping the COM host object layout unchanged.What changed
s_globalHostServicesfromIntPtrwith a small wrapper value type that contains the vtable pointer.[FixedAddressValueType]ons_globalHostServices, but now applied to a non-primitive value type where the runtime honors it.Why this is safer
FixedAddressValueTypebehavior forIntPtr.SetReferenceTrackerHost: a pointer to a single-field object whose first field is the vtable pointer.Shape