Uh oh!
There was an error while loading. Please reload this page.
Fix ReferenceTrackerHost fixed-address storage - #129669
Conversation
Tagging subscribers to this area: @dotnet/interop-contrib |
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
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.
Uh oh!
There was an error while loading. Please reload this page.
hamarb123
commented
Jun 21, 2026
(Btw, you can also just use |
jkotas
commented
Jun 22, 2026
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. |
Uh oh!
There was an error while loading. Please reload this page.
`ReferenceTrackerHost` stored `s_globalHostServices` as an `IntPtr` annotated 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. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
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