dotnet / dotnet/runtime

Avoid UB object reinterpret in builtin marshalling.

Open
#130,427 1 comment 0 reactions 0 assignees View on GitHub
area-Interop-coreclr
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

See https://github.com/dotnet/runtime/pull/130279#discussion_r3539930677

The safest solution would be to use a pinned local for the object reference (those are valid in IL) and then `conv.u` the object reference and add data offset to the pointer.

cc @MichalStrehovsky @AaronRobinsonMSFT do you maybe want to use copilot on this?

Contributor guide

Open the contributing guide

Research direction

Start with the linked pull request discussion and trace the builtin marshalling implementation it discusses. Replace the object reinterpretation approach with the proposed pinned local, `conv.u`, and data offset handling; done means the marshalling path no longer relies on undefined behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.