Fix exitCode from ExecuteAssembly
authorstephentoub <stoub@microsoft.com>
Thu, 28 May 2015 19:02:40 +0000 (15:02 -0400)
committerstephentoub <stoub@microsoft.com>
Fri, 29 May 2015 14:22:20 +0000 (10:22 -0400)
ExecuteAssembly is initializing exitCode to 0 on entrance to the function.  If it then fails prior to exitCode being set when invoking the entry point, the exitCode remains 0 even though there was a failure, and corerun ends up returning a successful exit code.

src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
src/dlls/mscoree/unixinterface.cpp

index e7323c1..4f6ffa0 100644 (file)
@@ -290,6 +290,7 @@ int ExecuteManagedAssembly(
             if (!SUCCEEDED(st))
             {
                 fprintf(stderr, "ExecuteAssembly failed - status: 0x%08x\n", st);
+                exitCode = -1;
             }
         }
         else
index 2eaa1b8..1cd9d67 100644 (file)
@@ -124,7 +124,11 @@ HRESULT ExecuteAssembly(
             LPCSTR entryPointMethodName,
             DWORD* exitCode)
 {
-    *exitCode = 0;
+    if (exitCode == NULL)
+    {
+        return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
+    }
+    *exitCode = -1;
 
     DWORD error = PAL_InitializeCoreCLR(exePath, coreClrPath, true);
     HRESULT hr = HRESULT_FROM_WIN32(error);