Skip to content

FCall implementation collision on Windows ARM64 #39701

@ladipro

Description

@ladipro

Multiple FCalls are implemented by the same native function on ARM64:

1:048> ln 00007ff9`b2d6d060
 [F:\workspace\_work\1\s\src\coreclr\src\vm\gchandleutilities.h @ 233] (00007ff9`b2d6d060)   coreclr!StoreObjectInHandle   |  (00007ff9`b2d6d0b8)   coreclr!EventPipe::Initialize
Exact matches:
    coreclr!StoreObjectInHandle (struct OBJECTHANDLE__ *, class Object *)
    coreclr!DependentHandle::nSetPrimary (struct OBJECTHANDLE__ *, class Object *)
    coreclr!MarshalNative::GCHandleInternalSet (struct OBJECTHANDLE__ *, class Object *)

Repro:

using System.IO;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var handle = GCHandle.Alloc("Hello1", GCHandleType.Weak);
            handle.Target = "Hello2";

            using (var stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, new Hashtable());
                stream.Seek(0, SeekOrigin.Begin);
                formatter.Deserialize(stream);
            }
        }
    }
}

Expected: Works fine.

Actual:

Unhandled exception. System.Runtime.Serialization.SerializationException: Invalid BinaryFormatter stream.
 ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (0x80004005 (E_FAIL))
   at System.Runtime.CompilerServices.DependentHandle.nSetPrimary(IntPtr dependentHandle, Object primary)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Container.Remove(TKey key)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Remove(TKey key)
   at System.Collections.Hashtable.OnDeserialization(Object sender)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions