From: Jim Ma Date: Fri, 7 Apr 2017 15:33:21 +0000 (+0800) Subject: Handle unsupported varargs tests on Unix gracefully. (dotnet/coreclr#10794) X-Git-Tag: submit/tizen/20210909.063632~11030^2~7374 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=813480260f15ab76267a4a4841461b73cb78c5eb;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Handle unsupported varargs tests on Unix gracefully. (dotnet/coreclr#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 dotnet/coreclr#9530 Commit migrated from https://github.com/dotnet/coreclr/commit/a86df0d0abe3ca5a7eed1db673c4ea48cfc3c61c --- diff --git a/src/coreclr/src/pal/src/loader/module.cpp b/src/coreclr/src/pal/src/loader/module.cpp index 63a65ff..bbe8b9d 100644 --- a/src/coreclr/src/pal/src/loader/module.cpp +++ b/src/coreclr/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/coreclr/src/vm/method.cpp b/src/coreclr/src/vm/method.cpp index 834ab63..a72b07b 100644 --- a/src/coreclr/src/vm/method.cpp +++ b/src/coreclr/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