Skip to content

Commit 0a962fc

Browse files
authored
Fix paltest_pal_sxs_test1 on illumos (#105207)
* Fix RPATH for exception handling PAL test * Don't use alternate stack on illumos or Solaris. When .NET translates SIGSEV to NullReferenceException, it does not return from the signal handler. Instead it resumes execution at the catch handler for the exception. This is not recommend by the manpage for sigaction(2): > It is not recommended that [the ucontext] arg be used by the handler to > restore the context from before the signal delivery. The practical effect of resuming execution without returning from a handler is that the alternate stack will not be used for subsequent signal delivery. This is in contrast to the behavior on linux, which will always use the alternate stack if the stack pointer at the time of fault does not fall on the alternate stack. Since the alternate stack is only usable for a single exception, don't bother using it for any exceptions.
1 parent 14eca7c commit 0a962fc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/coreclr/pal/src/exception/signal.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,13 @@ BOOL SEHInitializeSignals(CorUnix::CPalThread *pthrCurrent, DWORD flags)
190190
handle_signal(SIGSEGV, sigsegv_handler, &g_previous_sigsegv);
191191
#else
192192
handle_signal(SIGTRAP, sigtrap_handler, &g_previous_sigtrap);
193+
int additionalFlagsForSigSegv = 0;
194+
#ifndef TARGET_SUNOS
195+
// On platforms that support signal handlers that don't return,
193196
// SIGSEGV handler runs on a separate stack so that we can handle stack overflow
194-
handle_signal(SIGSEGV, sigsegv_handler, &g_previous_sigsegv, SA_ONSTACK);
197+
additionalFlagsForSigSegv |= SA_ONSTACK;
198+
#endif
199+
handle_signal(SIGSEGV, sigsegv_handler, &g_previous_sigsegv, additionalFlagsForSigSegv);
195200

196201
if (!pthrCurrent->EnsureSignalAlternateStack())
197202
{
@@ -344,7 +349,7 @@ Return :
344349
--*/
345350
bool IsRunningOnAlternateStack(void *context)
346351
{
347-
#if HAVE_MACH_EXCEPTIONS
352+
#if HAVE_MACH_EXCEPTIONS || defined(TARGET_SUNOS)
348353
return false;
349354
#else
350355
bool isRunningOnAlternateStack;

src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ endif(CLR_CMAKE_HOST_UNIX)
55
# Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY
66
# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling.
77
if(CORECLR_SET_RPATH)
8+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
89
if(CLR_CMAKE_HOST_OSX)
910
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
1011
set(CMAKE_INSTALL_NAME_DIR "@rpath")
11-
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
1212
set(CMAKE_INSTALL_RPATH "@loader_path")
13-
endif(CLR_CMAKE_HOST_OSX)
14-
if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_HAIKU)
15-
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
13+
else()
1614
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
17-
endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_HAIKU)
15+
endif(CLR_CMAKE_HOST_OSX)
1816
endif(CORECLR_SET_RPATH)
1917

2018
# Test DLL1

0 commit comments

Comments
 (0)