Handle unsupported varargs tests on Unix gracefully. (dotnet/coreclr#10794)
authorJim Ma <mazong1123@gmail.com>
Fri, 7 Apr 2017 15:33:21 +0000 (23:33 +0800)
committerJan Kotas <jkotas@microsoft.com>
Fri, 7 Apr 2017 15:33:21 +0000 (08:33 -0700)
Some of mcc_i* tests caused segmentation faults on Unix. This commit make these tests exit by throwing a System.EntryPointNotFoundException exception instead of causing a segmentation fault.

Fix dotnet/coreclr#9530

Commit migrated from https://github.com/dotnet/coreclr/commit/a86df0d0abe3ca5a7eed1db673c4ea48cfc3c61c

src/coreclr/src/pal/src/loader/module.cpp
src/coreclr/src/vm/method.cpp

index 63a65ff..bbe8b9d 100644 (file)
@@ -280,6 +280,16 @@ GetProcAddress(
 
     module = (MODSTRUCT *) hModule;
 
+    /* try to assert on attempt to locate symbol by ordinal */
+    /* this can't be an exact test for HIWORD((DWORD)lpProcName) == 0
+       because of the address range reserved for ordinals contain can
+       be a valid string address on non-Windows systems
+    */
+    if ((DWORD_PTR)lpProcName < VIRTUAL_PAGE_SIZE)
+    {
+        ASSERT("Attempt to locate symbol by ordinal?!\n");
+    }
+
     /* parameter validation */
 
     if ((lpProcName == nullptr) || (*lpProcName == '\0'))
@@ -295,16 +305,6 @@ GetProcAddress(
         SetLastError(ERROR_INVALID_HANDLE);
         goto done;
     }
-    
-    /* try to assert on attempt to locate symbol by ordinal */
-    /* this can't be an exact test for HIWORD((DWORD)lpProcName) == 0
-       because of the address range reserved for ordinals contain can
-       be a valid string address on non-Windows systems
-    */
-    if ((DWORD_PTR)lpProcName < VIRTUAL_PAGE_SIZE)
-    {
-        ASSERT("Attempt to locate symbol by ordinal?!\n");
-    }
 
     // Get the symbol's address.
     
index 834ab63..a72b07b 100644 (file)
@@ -5042,12 +5042,14 @@ LPVOID NDirectMethodDesc::FindEntryPoint(HINSTANCE hMod) const
     
     FARPROC pFunc = NULL, pFuncW = NULL;
 
+#ifndef FEATURE_PAL
     // Handle ordinals.
     if (GetEntrypointName()[0] == '#')
     {
         long ordinal = atol(GetEntrypointName()+1);
         return reinterpret_cast<LPVOID>(GetProcAddress(hMod, (LPCSTR)(size_t)((UINT16)ordinal)));
     }
+#endif
 
     // Just look for the unmangled name.  If it is unicode fcn, we are going
     // to need to check for the 'W' API because it takes precedence over the