From a86df0d0abe3ca5a7eed1db673c4ea48cfc3c61c Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Fri, 7 Apr 2017 23:33:21 +0800 Subject: Handle unsupported varargs tests on Unix gracefully. (#10794) 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 #9530 --- src/pal/src/loader/module.cpp | 20 ++++++++++---------- src/vm/method.cpp | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index 63a65ffb61..bbe8b9ddcc 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -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. diff --git a/src/vm/method.cpp b/src/vm/method.cpp index 834ab63d58..a72b07b404 100644 --- a/src/vm/method.cpp +++ b/src/vm/method.cpp @@ -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(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 -- cgit v1.2.3