@@ -188,7 +188,7 @@ BOOL SEHInitializeSignals(CorUnix::CPalThread *pthrCurrent, DWORD flags)
188188 handle_signal (SIGINT, sigint_handler, &g_previous_sigint, 0 /* additionalFlags */ , true /* skipIgnored */ );
189189 handle_signal (SIGQUIT, sigquit_handler, &g_previous_sigquit, 0 /* additionalFlags */ , true /* skipIgnored */ );
190190
191- #if HAVE_MACH_EXCEPTIONS
191+ #if HAVE_MACH_EXCEPTIONS || !HAVE_SIGALTSTACK
192192 handle_signal (SIGSEGV, sigsegv_handler, &g_previous_sigsegv);
193193#else
194194 handle_signal (SIGTRAP, sigtrap_handler, &g_previous_sigtrap);
@@ -569,6 +569,7 @@ extern "C" void signal_handler_worker(int code, siginfo_t *siginfo, void *contex
569569 RtlRestoreContext (&returnPoint->context , NULL );
570570}
571571
572+ #if HAVE_SIGALTSTACK
572573/* ++
573574Function :
574575 SwitchStackAndExecuteHandler
@@ -609,6 +610,7 @@ static bool SwitchStackAndExecuteHandler(int code, siginfo_t *siginfo, void *con
609610
610611 return pReturnPoint->returnFromHandler ;
611612}
613+ #endif
612614
613615#endif // !HAVE_MACH_EXCEPTIONS
614616
@@ -644,6 +646,10 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
644646 {
645647 if (GetCurrentPalThread ())
646648 {
649+ #if defined(TARGET_TVOS)
650+ (void )!write (STDERR_FILENO, StackOverflowMessage, sizeof (StackOverflowMessage) - 1 );
651+ PROCAbort (SIGSEGV, siginfo);
652+ #else // TARGET_TVOS
647653 size_t handlerStackTop = __sync_val_compare_and_swap ((size_t *)&g_stackOverflowHandlerStack, (size_t )g_stackOverflowHandlerStack, 0 );
648654 if (handlerStackTop == 0 )
649655 {
@@ -672,6 +678,7 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
672678 PROCAbort (SIGSEGV, siginfo);
673679 }
674680 (void )!write (STDERR_FILENO, StackOverflowHandlerReturnedMessage, sizeof (StackOverflowHandlerReturnedMessage) - 1 );
681+ #endif // TARGET_TVOS
675682 }
676683 else
677684 {
@@ -686,6 +693,7 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
686693 // Now that we know the SIGSEGV didn't happen due to a stack overflow, execute the common
687694 // hardware signal handler on the original stack.
688695
696+ #if HAVE_SIGALTSTACK
689697 if (GetCurrentPalThread () && IsRunningOnAlternateStack (context))
690698 {
691699 if (SwitchStackAndExecuteHandler (code, siginfo, context, 0 /* sp */ )) // sp == 0 indicates execution on the original stack
@@ -694,6 +702,7 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
694702 }
695703 }
696704 else
705+ #endif
697706 {
698707 // The code flow gets here when the signal handler is not running on an alternate stack or when it wasn't created
699708 // by coreclr. In both cases, we execute the common_signal_handler directly.
0 commit comments