Fix Exception Propagation issue for NetCoreForCoreCLR Non-AppX case
authorLuqun Lou <luqunl@microsoft.com>
Wed, 10 Jun 2015 22:53:48 +0000 (15:53 -0700)
committerLuqun Lou <luqunl@microsoft.com>
Wed, 10 Jun 2015 22:53:48 +0000 (15:53 -0700)
Currently in CoreCLR, We don't propagate managed exception from Managed->Native->Managed correctly for non-appx case--- if you throw a managed exception, then during M->N, the managed exception is stored in thread, later during N->M, we will try to fetch this stored exception if it is managed exception by checking IsManagedObject()

The logical for IsManagedObject should be just check its IUnknown slots first no matter whether it is appx or not; If doesn't match, try to QI IManagedObject.

[tfs-changeset: 1486094]

src/vm/interoputil.cpp

index ca668c5..6f672c0 100644 (file)
@@ -549,17 +549,15 @@ BOOL IsManagedObject(IUnknown *pIUnknown)
     }
     CONTRACTL_END;
 
-    if (AppX::IsAppXProcess())
+    //Check based on IUnknown slots, i.e. we'll see whether the IP maps to a CCW.
+    if (MapIUnknownToWrapper(pIUnknown) != NULL)
     {
-        //In AppX we don't support IManagedObject so we'll do the check based on
-        //IUnknown slots, i.e. we'll see whether the IP maps to a CCW.
-        if (MapIUnknownToWrapper(pIUnknown) != NULL)
-        {
-            // We found an existing CCW hence this is a managed exception.
-            return TRUE;
-        }
+        // We found an existing CCW hence this is a managed exception.
+        return TRUE;
     }
-    else
+    
+    // QI IManagedObject. Note AppX doesn't support IManagedObject
+    if (!AppX::IsAppXProcess())
     {
         SafeComHolder<IManagedObject> pManagedObject = NULL;
         HRESULT hrLocal = SafeQueryInterface(pIUnknown, IID_IManagedObject, (IUnknown**)&pManagedObject);