Przeglądaj źródła

[MERGE #2170 @obastemur] Release/2.0 pre to Master

Merge pull request #2170 from release/2.0-pre

/cc @digitalinfinity
Oguz Bastemur 9 lat temu
rodzic
commit
aff294cc4f

+ 0 - 1
bin/ch/CMakeLists.txt

@@ -62,7 +62,6 @@ if(STATIC_LIBRARY)
   if(CMAKE_SYSTEM_NAME STREQUAL Linux)
     set(lib_target "${lib_target}"
       ${ICULIB}
-      unwind-x86_64
       )
   elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
     set(lib_target "${lib_target}"

+ 1 - 1
build.sh

@@ -363,7 +363,7 @@ else
             "\nSection: base"\
             "\nPriority: optional"\
             "\nArchitecture: amd64"\
-            "\nDepends: libc6 (>= 2.19), uuid-dev (>> 0), libunwind-dev (>> 0), libicu-dev (>> 0)"\
+            "\nDepends: libc6 (>= 2.19), uuid-dev (>> 0), libicu-dev (>> 0)"\
             "\nMaintainer: ChakraCore <[email protected]>"\
             "\nDescription: Chakra Core"\
             "\n Open source Core of Chakra Javascript Engine"\

+ 2 - 2
lib/Common/ChakraCoreVersion.h

@@ -15,8 +15,8 @@
 // --------------
 
 // ChakraCore version number definitions (used in ChakraCore binary metadata)
-#define CHAKRA_CORE_MAJOR_VERSION 1
-#define CHAKRA_CORE_MINOR_VERSION 4
+#define CHAKRA_CORE_MAJOR_VERSION 2
+#define CHAKRA_CORE_MINOR_VERSION 0
 #define CHAKRA_CORE_PATCH_VERSION 0
 #define CHAKRA_CORE_VERSION_RELEASE_QFE 0 // Redundant with PATCH_VERSION. Keep this value set to 0.
 

+ 9 - 5
lib/Common/CommonDefines.h

@@ -362,13 +362,17 @@
 #define TTD_LOG_READER TextFormatReader
 #define TTD_LOG_WRITER TextFormatWriter
 
-#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
+//For now always use the (lower performance) text format for snapshots for easier debugging etc.
 #define TTD_SNAP_READER TextFormatReader
 #define TTD_SNAP_WRITER TextFormatWriter
-#else
-#define TTD_SNAP_READER BinaryFormatReader
-#define TTD_SNAP_WRITER BinaryFormatWriter
-#endif
+
+//#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
+//#define TTD_SNAP_READER TextFormatReader
+//#define TTD_SNAP_WRITER TextFormatWriter
+//#else
+//#define TTD_SNAP_READER BinaryFormatReader
+//#define TTD_SNAP_WRITER BinaryFormatWriter
+//#endif
 
 #if ENABLE_TTD_INTERNAL_DIAGNOSTICS
 #define ENABLE_SNAPSHOT_COMPARE 1

+ 5 - 0
lib/Common/ConfigFlagsList.h

@@ -649,7 +649,12 @@ PHASE(All)
 #define DEFAULT_CONFIG_EnumerationCompat    (false)
 #define DEFAULT_CONFIG_ConcurrentRuntime (false)
 #define DEFAULT_CONFIG_PrimeRecycler     (false)
+#if defined(_WIN32)
 #define DEFAULT_CONFIG_PrivateHeap       (true)
+#else // defined(_WIN32)
+// Don't use PrivateHeap on xplat where we statically link and override new/delete
+#define DEFAULT_CONFIG_PrivateHeap       (false)
+#endif // defined(_WIN32)
 #define DEFAULT_CONFIG_DisableRentalThreading (false)
 #define DEFAULT_CONFIG_DisableDebugObject (false)
 #define DEFAULT_CONFIG_DumpHeap (false)

+ 1 - 0
lib/Common/Exceptions/Throw.cpp

@@ -71,6 +71,7 @@ namespace Js {
         int scenario = 2;
         ReportFatalException(NULL, E_FAIL, Fatal_Internal_Error, scenario);
     }
+
     void Throw::FatalInternalErrorEx(int scenario)
     {
         ReportFatalException(NULL, E_FAIL, Fatal_Internal_Error, scenario);

+ 15 - 0
lib/Runtime/Debug/TTEventLog.cpp

@@ -2974,6 +2974,17 @@ namespace TTD
 
         writer.WriteString(NSTokens::Key::arch, archString);
 
+        TTString platformString;
+#if defined(_WIN32)
+        this->m_miscSlabAllocator.CopyNullTermStringInto(_u("Windows"), platformString);
+#elif defined(__APPLE__)
+        this->m_miscSlabAllocator.CopyNullTermStringInto(_u("macOS"), platformString);
+#else
+        this->m_miscSlabAllocator.CopyNullTermStringInto(_u("Linux"), platformString);
+#endif
+
+        writer.WriteString(NSTokens::Key::platform, platformString);
+
 #if ENABLE_TTD_INTERNAL_DIAGNOSTICS
         bool diagEnabled = true;
 #else
@@ -3167,6 +3178,10 @@ namespace TTD
         TTDAssert(false, "Unknown arch!!!");
 #endif
 
+        //This is informational only so just read off the value and ignore
+        TTString platformString;
+        reader.ReadString(NSTokens::Key::platform, this->m_miscSlabAllocator, platformString);
+
         bool diagEnabled = reader.ReadBool(NSTokens::Key::diagEnabled, true);
 
 #if ENABLE_TTD_INTERNAL_DIAGNOSTICS

+ 2 - 0
lib/Runtime/Debug/TTSerialize.cpp

@@ -1631,6 +1631,7 @@ namespace TTD
         {
             alloc.InitializeAndAllocateWLength(sizeField, into);
             this->ReadBytesInto((byte*)into.Contents, into.Length * sizeof(char16));
+            into.Contents[into.Length] = '\0';
         }
     }
 
@@ -1649,6 +1650,7 @@ namespace TTD
         {
             alloc.InitializeAndAllocateWLength(sizeField, into);
             this->ReadBytesInto((byte*)into.Contents, into.Length * sizeof(char16));
+            into.Contents[into.Length] = '\0';
         }
     }
 

+ 1 - 0
lib/Runtime/Debug/TTSerializeEnum.h

@@ -111,6 +111,7 @@ ENTRY_SERIALIZE_ENUM(isSymbol)
 ENTRY_SERIALIZE_ENUM(isValid)
 
 ENTRY_SERIALIZE_ENUM(arch)
+ENTRY_SERIALIZE_ENUM(platform)
 ENTRY_SERIALIZE_ENUM(diagEnabled)
 ENTRY_SERIALIZE_ENUM(timeTotal)
 ENTRY_SERIALIZE_ENUM(timeMark)

+ 0 - 300
pal/inc/pal.h

@@ -6985,310 +6985,10 @@ public:
 
 #endif // FEATURE_PAL_SXS
 
-#ifdef __cplusplus
-
-#include "pal_unwind.h"
-
 #define EXCEPTION_CONTINUE_SEARCH   0
 #define EXCEPTION_EXECUTE_HANDLER   1
 #define EXCEPTION_CONTINUE_EXECUTION -1
 
-struct PAL_SEHException
-{
-private:
-    const SIZE_T NoTargetFrameSp = SIZE_MAX;
-public:
-    // Note that the following two are actually embedded in this heap-allocated
-    // instance - in contrast to Win32, where the exception record would usually
-    // be allocated on the stack.  This is needed because foreign cleanup handlers
-    // partially unwind the stack on the second pass.
-    EXCEPTION_POINTERS ExceptionPointers;
-    EXCEPTION_RECORD ExceptionRecord;
-    CONTEXT ContextRecord;
-    // Target frame stack pointer set before the 2nd pass.
-    SIZE_T TargetFrameSp;
-
-    PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord)
-    {
-        ExceptionPointers.ExceptionRecord = &ExceptionRecord;
-        ExceptionPointers.ContextRecord = &ContextRecord;
-        ExceptionRecord = *pExceptionRecord;
-        ContextRecord = *pContextRecord;
-        TargetFrameSp = NoTargetFrameSp;
-    }
-
-    PAL_SEHException()
-    {
-    }
-
-    PAL_SEHException(const PAL_SEHException& ex)
-    {
-        *this = ex;
-    }
-
-    bool IsFirstPass()
-    {
-        return (TargetFrameSp == NoTargetFrameSp);
-    }
-
-    PAL_SEHException& operator=(const PAL_SEHException& ex)
-    {
-        ExceptionPointers.ExceptionRecord = &ExceptionRecord;
-        ExceptionPointers.ContextRecord = &ContextRecord;
-        ExceptionRecord = ex.ExceptionRecord;
-        ContextRecord = ex.ContextRecord;
-        TargetFrameSp = ex.TargetFrameSp;
-
-        return *this;
-    }
-};
-
-typedef BOOL (PALAPI *PHARDWARE_EXCEPTION_HANDLER)(PAL_SEHException* ex);
-typedef DWORD (PALAPI *PGET_GCMARKER_EXCEPTION_CODE)(LPVOID ip);
-
-PALIMPORT
-VOID
-PALAPI
-PAL_SetHardwareExceptionHandler(
-    IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler);
-
-//
-// This holder is used to indicate that a hardware
-// exception should be raised as a C++ exception
-// to better emulate SEH on the xplat platforms.
-//
-class CatchHardwareExceptionHolder
-{
-public:
-    CatchHardwareExceptionHolder();
-
-    ~CatchHardwareExceptionHolder();
-
-    static bool IsEnabled();
-};
-
-//
-// NOTE: Catching hardware exceptions are only enabled in the DAC and SOS
-// builds. A hardware exception in coreclr code will fail fast/terminate
-// the process.
-//
-#ifdef FEATURE_ENABLE_HARDWARE_EXCEPTIONS
-#define HardwareExceptionHolder CatchHardwareExceptionHolder __catchHardwareException;
-#else
-#define HardwareExceptionHolder
-#endif // FEATURE_ENABLE_HARDWARE_EXCEPTIONS
-
-#ifdef FEATURE_PAL_SXS
-
-extern "C++" {
-
-//
-// This is the base class of native exception holder used to provide
-// the filter function to the exception dispatcher. This allows the
-// filter to be called during the first pass to better emulate SEH
-// the xplat platforms that only have C++ exception support.
-//
-class NativeExceptionHolderBase
-{
-    // Save the address of the holder head so the destructor
-    // doesn't have access the slow (on Linux) TLS value again.
-    NativeExceptionHolderBase **m_head;
-
-    // The next holder on the stack
-    NativeExceptionHolderBase *m_next;
-
-protected:
-    NativeExceptionHolderBase();
-
-    ~NativeExceptionHolderBase();
-
-public:
-    // Calls the holder's filter handler.
-    virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) = 0;
-
-    // Adds the holder to the "stack" of holders. This is done explicitly instead
-    // of in the constructor was to avoid the mess of move constructors combined
-    // with return value optimization (in CreateHolder).
-    void Push();
-
-    // Given the currentHolder and locals stack range find the next holder starting with this one
-    // To find the first holder, pass nullptr as the currentHolder.
-    static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, void *frameLowAddress, void *frameHighAddress);
-};
-
-//
-// This is the second part of the native exception filter holder. It is
-// templated because the lambda used to wrap the exception filter is a
-// unknown type.
-//
-template<class FilterType>
-class NativeExceptionHolder : public NativeExceptionHolderBase
-{
-    FilterType* m_exceptionFilter;
-
-public:
-    NativeExceptionHolder(FilterType* exceptionFilter)
-        : NativeExceptionHolderBase()
-    {
-        m_exceptionFilter = exceptionFilter;
-    }
-
-    virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
-    {
-        return (*m_exceptionFilter)(ex);
-    }
-};
-
-//
-// This is a native exception holder that is used when the catch catches
-// all exceptions.
-//
-class NativeExceptionHolderCatchAll : public NativeExceptionHolderBase
-{
-
-public:
-    NativeExceptionHolderCatchAll()
-        : NativeExceptionHolderBase()
-    {
-    }
-
-    virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
-    {
-        return EXCEPTION_EXECUTE_HANDLER;
-    }
-};
-
-//
-// This factory class for the native exception holder is necessary because
-// templated functions don't need the explicit type parameter and can infer
-// the template type from the parameter.
-//
-class NativeExceptionHolderFactory
-{
-public:
-    template<class FilterType>
-    static NativeExceptionHolder<FilterType> CreateHolder(FilterType* exceptionFilter)
-    {
-        return NativeExceptionHolder<FilterType>(exceptionFilter);
-    }
-};
-
-// Start of a try block for exceptions raised by RaiseException
-#define PAL_TRY(__ParamType, __paramDef, __paramRef)                            \
-{                                                                               \
-    __ParamType __param = __paramRef;                                           \
-    auto tryBlock = [](__ParamType __paramDef)                                  \
-    {
-
-// Start of an exception handler. If an exception raised by the RaiseException
-// occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER,
-// the handler code is executed. If the disposition is EXCEPTION_CONTINUE_SEARCH,
-// the exception is rethrown. The EXCEPTION_CONTINUE_EXECUTION disposition is
-// not supported.
-#define PAL_EXCEPT(dispositionExpression)                                       \
-    };                                                                          \
-    const bool isFinally = false;                                               \
-    auto finallyBlock = []() {};                                                \
-    EXCEPTION_DISPOSITION disposition = EXCEPTION_CONTINUE_EXECUTION;           \
-    auto exceptionFilter = [&disposition, &__param](PAL_SEHException& ex)       \
-    {                                                                           \
-        disposition = dispositionExpression;                                    \
-        _ASSERTE(disposition != EXCEPTION_CONTINUE_EXECUTION);                  \
-        return disposition;                                                     \
-    };                                                                          \
-    try                                                                         \
-    {                                                                           \
-        HardwareExceptionHolder                                                 \
-        auto __exceptionHolder = NativeExceptionHolderFactory::CreateHolder(&exceptionFilter); \
-        __exceptionHolder.Push();                                               \
-        tryBlock(__param);                                                      \
-    }                                                                           \
-    catch (PAL_SEHException& ex)                                                \
-    {                                                                           \
-        if (disposition == EXCEPTION_CONTINUE_EXECUTION)                        \
-        {                                                                       \
-            exceptionFilter(ex);                                                \
-        }                                                                       \
-        if (disposition == EXCEPTION_CONTINUE_SEARCH)                           \
-        {                                                                       \
-            throw;                                                              \
-        }
-
-// Start of an exception handler. It works the same way as the PAL_EXCEPT except
-// that the disposition is obtained by calling the specified filter.
-#define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(&ex.ExceptionPointers, __param))
-
-// Start of a finally block. The finally block is executed both when the try block
-// finishes or when an exception is raised using the RaiseException in it.
-#define PAL_FINALLY                     \
-    };                                  \
-    const bool isFinally = true;        \
-    auto finallyBlock = [&]()           \
-    {
-
-// End of an except or a finally block.
-#define PAL_ENDTRY                      \
-    };                                  \
-    if (isFinally)                      \
-    {                                   \
-        try                             \
-        {                               \
-            tryBlock(__param);          \
-        }                               \
-        catch (...)                     \
-        {                               \
-            finallyBlock();             \
-            throw;                      \
-        }                               \
-        finallyBlock();                 \
-    }                                   \
-}
-
-} // extern "C++"
-
-#endif // FEATURE_PAL_SXS
-
-#define PAL_CPP_THROW(type, obj) { throw obj; }
-#define PAL_CPP_RETHROW { throw; }
-#define PAL_CPP_TRY                     try { HardwareExceptionHolder
-#define PAL_CPP_CATCH_EXCEPTION(ident)  } catch (Exception *ident) { PAL_Reenter(PAL_BoundaryBottom);
-#define PAL_CPP_CATCH_EXCEPTION_NOARG   } catch (Exception *) { PAL_Reenter(PAL_BoundaryBottom);
-#define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { PAL_Reenter(PAL_BoundaryBottom);
-#define PAL_CPP_CATCH_ALL               } catch (...) { PAL_Reenter(PAL_BoundaryBottom);
-#define PAL_CPP_ENDTRY                  }
-
-#ifdef _MSC_VER
-#pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
-#endif
-
-#ifdef FEATURE_PAL_SXS
-
-#define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) PAL_TRY(ParamType, paramDef, paramRef)
-
-#else // FEATURE_PAL_SXS
-
-#define PAL_TRY(ParamType, paramDef, paramRef)                          \
-    {                                                                   \
-        ParamType __param = paramRef;                                   \
-        ParamType paramDef; paramDef = __param;                         \
-        try {                                                           \
-            HardwareExceptionHolder
-
-#define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason)     \
-    {                                                                   \
-        ParamType __param = paramRef;                                   \
-        ParamType paramDef; paramDef = __param;                         \
-        try {                                                           \
-            HardwareExceptionHolder
-
-#define PAL_ENDTRY                                                      \
-        }                                                               \
-    }
-
-#endif // FEATURE_PAL_SXS
-
-#endif // __cplusplus
-
 // Platform-specific library naming
 //
 #ifdef PLATFORM_UNIX

+ 0 - 92
pal/inc/pal_unwind.h

@@ -1,92 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
-//
-
-//
-// Definition of the Unwind API functions.
-// Taken from the ABI documentation.
-//
-
-
-
-#ifndef __PAL_UNWIND_H__
-#define __PAL_UNWIND_H__
-
-#if FEATURE_PAL_SXS
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-
-    //
-    // Exception Handling ABI Level I: Base ABI
-    //
-
-    typedef enum
-    {
-        _URC_NO_REASON = 0,
-        _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
-        _URC_FATAL_PHASE2_ERROR = 2,
-        _URC_FATAL_PHASE1_ERROR = 3,
-        _URC_NORMAL_STOP = 4,
-        _URC_END_OF_STACK = 5,
-        _URC_HANDLER_FOUND = 6,
-        _URC_INSTALL_CONTEXT = 7,
-        _URC_CONTINUE_UNWIND = 8,
-    } _Unwind_Reason_Code;
-
-    typedef enum
-    {
-        _UA_SEARCH_PHASE = 1,
-        _UA_CLEANUP_PHASE = 2,
-        _UA_HANDLER_FRAME = 4,
-        _UA_FORCE_UNWIND = 8,
-    } _Unwind_Action;
-    #define _UA_PHASE_MASK (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)
-
-    struct _Unwind_Context;
-
-    void *_Unwind_GetIP(struct _Unwind_Context *context);
-    void _Unwind_SetIP(struct _Unwind_Context *context, void *new_value);
-    void *_Unwind_GetCFA(struct _Unwind_Context *context);
-    void *_Unwind_GetGR(struct _Unwind_Context *context, int index);
-    void _Unwind_SetGR(struct _Unwind_Context *context, int index, void *new_value);
-
-    struct _Unwind_Exception;
-
-    typedef void (*_Unwind_Exception_Cleanup_Fn)(
-        _Unwind_Reason_Code urc,
-        struct _Unwind_Exception *exception_object);
-
-    struct _Unwind_Exception
-    {
-        ULONG64 exception_class;
-        _Unwind_Exception_Cleanup_Fn exception_cleanup;
-        UINT_PTR private_1;
-        UINT_PTR private_2;
-    } __attribute__((aligned));
-
-    void _Unwind_DeleteException(struct _Unwind_Exception *exception_object);
-
-    typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *context, void *pvParam);
-    _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn pfnTrace, void *pvParam);
-
-    _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *exception_object);
-    __attribute__((noreturn)) void _Unwind_Resume(struct _Unwind_Exception *exception_object);
-
-    //
-    // Exception Handling ABI Level II: C++ ABI
-    //
-
-    void *__cxa_begin_catch(void *exceptionObject);
-    void __cxa_end_catch();
-
-#ifdef __cplusplus
-};
-#endif // __cplusplus
-
-#endif // FEATURE_PAL_SXS
-
-#endif // __PAL_UNWIND_H__

+ 0 - 1
pal/src/config.h.in

@@ -11,7 +11,6 @@
 #cmakedefine01 HAVE_SYS_TIME_H
 #cmakedefine01 HAVE_PTHREAD_NP_H
 #cmakedefine01 HAVE_SYS_LWP_H
-#cmakedefine01 HAVE_LIBUNWIND_H
 #cmakedefine01 HAVE_LIBUUID_H
 #cmakedefine01 HAVE_BSD_UUID_H
 #cmakedefine01 HAVE_RUNETYPE_H

+ 0 - 9
pal/src/configure.cmake

@@ -28,7 +28,6 @@ check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H)
 check_include_files(sys/time.h HAVE_SYS_TIME_H)
 check_include_files(pthread_np.h HAVE_PTHREAD_NP_H)
 check_include_files(sys/lwp.h HAVE_SYS_LWP_H)
-check_include_files(libunwind.h HAVE_LIBUNWIND_H)
 check_include_files(runetype.h HAVE_RUNETYPE_H)
 check_include_files(unicode/uchar.h HAVE_LIBICU_UCHAR_H)
 
@@ -882,10 +881,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
   set(ZH_TW_LOCALE_NAME zh_TG.BIG5)
   set(HAS_FTRUNCATE_LENGTH_ISSUE 1)
 elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
-  if(NOT HAVE_LIBUNWIND_H)
-    unset(HAVE_LIBUNWIND_H CACHE)
-    message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
-  endif()
   set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
   set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))")
   set(PAL_PT_ATTACH PT_ATTACH)
@@ -903,10 +898,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
     message(FATAL_ERROR "Cannot find libc on this system.")
   endif()
 else() # Anything else is Linux
-  if(NOT HAVE_LIBUNWIND_H)
-    unset(HAVE_LIBUNWIND_H CACHE)
-    message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
-  endif()
   set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
   set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))")
   set(PAL_PT_ATTACH PTRACE_ATTACH)

+ 8 - 20
pal/src/debug/debug.cpp

@@ -625,26 +625,20 @@ ReadProcessMemory(
         param.numberOfBytesRead = numberOfBytesRead;
         param.ret = ret;
 
-        PAL_TRY(Param *, pParam, &param)
         {
             SIZE_T i;
 
             // Seg fault in memcpy can't be caught
             // so we simulate the memcpy here
 
-            for (i = 0; i<pParam->nSize; i++)
+            for (i = 0; i<param.nSize; i++)
             {
-                *((char*)(pParam->lpBuffer)+i) = *((char*)(pParam->lpBaseAddress)+i);
+                *((char*)(param.lpBuffer)+i) = *((char*)(param.lpBaseAddress)+i);
             }
 
-            pParam->numberOfBytesRead = pParam->nSize;
-            pParam->ret = TRUE;
+            param.numberOfBytesRead = param.nSize;
+            param.ret = TRUE;
         }
-        PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-        {
-            SetLastError(ERROR_ACCESS_DENIED);
-        }
-        PAL_ENDTRY
 
         numberOfBytesRead = param.numberOfBytesRead;
         ret = param.ret;
@@ -923,26 +917,20 @@ WriteProcessMemory(
         param.numberOfBytesWritten = numberOfBytesWritten;
         param.ret = ret;
 
-        PAL_TRY(Param *, pParam, &param)
         {
             SIZE_T i;
 
             // Seg fault in memcpy can't be caught
             // so we simulate the memcpy here
 
-            for (i = 0; i<pParam->nSize; i++)
+            for (i = 0; i<param.nSize; i++)
             {
-                *((char*)(pParam->lpBaseAddress)+i) = *((char*)(pParam->lpBuffer)+i);
+                *((char*)(param.lpBaseAddress)+i) = *((char*)(param.lpBuffer)+i);
             }
 
-            pParam->numberOfBytesWritten = pParam->nSize;
-            pParam->ret = TRUE;
-        }
-        PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-        {
-            SetLastError(ERROR_ACCESS_DENIED);
+            param.numberOfBytesWritten = param.nSize;
+            param.ret = TRUE;
         }
-        PAL_ENDTRY
 
         numberOfBytesWritten = param.numberOfBytesWritten;
         ret = param.ret;

+ 2 - 7
pal/src/exception/machexception.cpp

@@ -19,7 +19,6 @@ Abstract:
 SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first
 
 #include "pal/thread.hpp"
-#include "pal/seh.hpp"
 #include "pal/palinternal.h"
 #if HAVE_MACH_EXCEPTIONS
 #include "machexception.h"
@@ -557,12 +556,8 @@ void PAL_DispatchException(DWORD64 dwRDI, DWORD64 dwRSI, DWORD64 dwRDX, DWORD64
     }
 #endif // FEATURE_PAL_SXS
 
-    EXCEPTION_POINTERS pointers;
-    pointers.ExceptionRecord = pExRecord;
-    pointers.ContextRecord = pContext;
-
-    NONPAL_TRACE("PAL_DispatchException(EC %08x EA %p)\n", pExRecord->ExceptionCode, pExRecord->ExceptionAddress);
-    SEHProcessException(&pointers);
+    raise(SIGINT);
+    abort();
 }
 
 #if defined(_X86_) || defined(_AMD64_)

+ 0 - 659
pal/src/exception/seh-unwind.cpp

@@ -1,659 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Copyright (c) Geoff Norton. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*++
-
-
-
-Module Name:
-
-    seh-unwind.cpp
-
-Abstract:
-
-    Implementation of exception API functions based on
-    the Unwind API.
-
-
-
---*/
-
-#ifndef FEATURE_PAL_SXS
-#error FEATURE_PAL_SXS needs to be defined for this file.
-#endif // !FEATURE_PAL_SXS
-
-#include "pal/context.h"
-#include "pal.h"
-#include <dlfcn.h>
-
-#if HAVE_LIBUNWIND_H
-#ifndef __LINUX__
-#define UNW_LOCAL_ONLY
-#endif // !__LINUX__
-#include <libunwind.h>
-#ifdef __LINUX__
-#ifdef HAVE_LIBUNWIND_PTRACE
-#include <libunwind-ptrace.h>
-#endif // HAVE_LIBUNWIND_PTRACE
-#endif // __LINUX__
-#endif // HAVE_LIBUNWIND_H
-
-
-//----------------------------------------------------------------------
-// Virtual Unwinding
-//----------------------------------------------------------------------
-
-#if HAVE_LIBUNWIND_H
-#if UNWIND_CONTEXT_IS_UCONTEXT_T
-
-#if defined(_AMD64_)
-#define ASSIGN_UNWIND_REGS \
-    ASSIGN_REG(Rip)        \
-    ASSIGN_REG(Rsp)        \
-    ASSIGN_REG(Rbp)        \
-    ASSIGN_REG(Rbx)        \
-    ASSIGN_REG(R12)        \
-    ASSIGN_REG(R13)        \
-    ASSIGN_REG(R14)        \
-    ASSIGN_REG(R15)
-#elif defined(_ARM64_)
-#define ASSIGN_UNWIND_REGS \
-    ASSIGN_REG(Pc)         \
-    ASSIGN_REG(Sp)         \
-    ASSIGN_REG(Fp)         \
-    ASSIGN_REG(Lr)         \
-    ASSIGN_REG(X19)        \
-    ASSIGN_REG(X20)        \
-    ASSIGN_REG(X21)        \
-    ASSIGN_REG(X22)        \
-    ASSIGN_REG(X23)        \
-    ASSIGN_REG(X24)        \
-    ASSIGN_REG(X25)        \
-    ASSIGN_REG(X26)        \
-    ASSIGN_REG(X27)        \
-    ASSIGN_REG(X28)
-#else
-#error unsupported architecture
-#endif
-
-static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext)
-{
-#define ASSIGN_REG(reg) MCREG_##reg(unwContext->uc_mcontext) = winContext->reg;
-    ASSIGN_UNWIND_REGS
-#undef ASSIGN_REG
-}
-#else
-static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor)
-{
-#if defined(_AMD64_)
-    unw_set_reg(cursor, UNW_REG_IP, winContext->Rip);
-    unw_set_reg(cursor, UNW_REG_SP, winContext->Rsp);
-    unw_set_reg(cursor, UNW_X86_64_RBP, winContext->Rbp);
-    unw_set_reg(cursor, UNW_X86_64_RBX, winContext->Rbx);
-    unw_set_reg(cursor, UNW_X86_64_R12, winContext->R12);
-    unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13);
-    unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14);
-    unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15);
-#elif defined(_ARM_)
-    unw_set_reg(cursor, UNW_ARM_R13, winContext->Sp);
-    unw_set_reg(cursor, UNW_ARM_R14, winContext->Lr);
-    unw_set_reg(cursor, UNW_ARM_R15, winContext->Pc);
-    unw_set_reg(cursor, UNW_ARM_R4, winContext->R4);
-    unw_set_reg(cursor, UNW_ARM_R5, winContext->R5);
-    unw_set_reg(cursor, UNW_ARM_R6, winContext->R6);
-    unw_set_reg(cursor, UNW_ARM_R7, winContext->R7);
-    unw_set_reg(cursor, UNW_ARM_R8, winContext->R8);
-    unw_set_reg(cursor, UNW_ARM_R9, winContext->R9);
-    unw_set_reg(cursor, UNW_ARM_R10, winContext->R10);
-    unw_set_reg(cursor, UNW_ARM_R11, winContext->R11);
-#endif
-}
-#endif
-
-static void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
-{
-#if defined(_AMD64_)
-    unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip);
-    unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp);
-    unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp);
-    unw_get_reg(cursor, UNW_X86_64_RBX, (unw_word_t *) &winContext->Rbx);
-    unw_get_reg(cursor, UNW_X86_64_R12, (unw_word_t *) &winContext->R12);
-    unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13);
-    unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14);
-    unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15);
-#elif defined(__i686__)
-    unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip);
-    unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp);
-    unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp);
-    unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx);
-#elif defined(_ARM_)
-    unw_get_reg(cursor, UNW_ARM_R13, (unw_word_t *) &winContext->Sp);
-    unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr);
-    unw_get_reg(cursor, UNW_ARM_R15, (unw_word_t *) &winContext->Pc);
-    unw_get_reg(cursor, UNW_ARM_R4, (unw_word_t *) &winContext->R4);
-    unw_get_reg(cursor, UNW_ARM_R5, (unw_word_t *) &winContext->R5);
-    unw_get_reg(cursor, UNW_ARM_R6, (unw_word_t *) &winContext->R6);
-    unw_get_reg(cursor, UNW_ARM_R7, (unw_word_t *) &winContext->R7);
-    unw_get_reg(cursor, UNW_ARM_R8, (unw_word_t *) &winContext->R8);
-    unw_get_reg(cursor, UNW_ARM_R9, (unw_word_t *) &winContext->R9);
-    unw_get_reg(cursor, UNW_ARM_R10, (unw_word_t *) &winContext->R10);
-    unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11);
-#elif defined(_ARM64_)
-    unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc);
-    unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp);
-    unw_get_reg(cursor, UNW_AARCH64_X29, (unw_word_t *) &winContext->Fp);
-    unw_get_reg(cursor, UNW_AARCH64_X30, (unw_word_t *) &winContext->Lr);
-    unw_get_reg(cursor, UNW_AARCH64_X19, (unw_word_t *) &winContext->X19);
-    unw_get_reg(cursor, UNW_AARCH64_X20, (unw_word_t *) &winContext->X20);
-    unw_get_reg(cursor, UNW_AARCH64_X21, (unw_word_t *) &winContext->X21);
-    unw_get_reg(cursor, UNW_AARCH64_X22, (unw_word_t *) &winContext->X22);
-    unw_get_reg(cursor, UNW_AARCH64_X23, (unw_word_t *) &winContext->X23);
-    unw_get_reg(cursor, UNW_AARCH64_X24, (unw_word_t *) &winContext->X24);
-    unw_get_reg(cursor, UNW_AARCH64_X25, (unw_word_t *) &winContext->X25);
-    unw_get_reg(cursor, UNW_AARCH64_X26, (unw_word_t *) &winContext->X26);
-    unw_get_reg(cursor, UNW_AARCH64_X27, (unw_word_t *) &winContext->X27);
-    unw_get_reg(cursor, UNW_AARCH64_X28, (unw_word_t *) &winContext->X28);
-#else
-#error unsupported architecture
-#endif
-}
-
-static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, SIZE_T **contextPointer)
-{
-#if defined(__APPLE__)
-    // Returning NULL indicates that we don't have context pointers available
-    *contextPointer = NULL;
-#else
-    unw_save_loc_t saveLoc;
-    unw_get_save_loc(cursor, reg, &saveLoc);
-    if (saveLoc.type == UNW_SLT_MEMORY)
-    {
-        SIZE_T *pLoc = (SIZE_T *)saveLoc.u.addr;
-        // Filter out fake save locations that point to unwContext
-        if ((pLoc < (SIZE_T *)unwContext) || ((SIZE_T *)(unwContext + 1) <= pLoc))
-            *contextPointer = (SIZE_T *)saveLoc.u.addr;
-    }
-#endif
-}
-
-#if defined(_AMD64_) || defined(_ARM_) || defined(_ARM64_)
-static void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers)
-{
-#if defined(_AMD64_)
-    GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp);
-    GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx);
-    GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12);
-    GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13);
-    GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14);
-    GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15);
-#elif defined(_ARM_)
-    GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R6, &contextPointers->R6);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R7, &contextPointers->R7);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R8, &contextPointers->R8);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R9, &contextPointers->R9);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10);
-    GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11);
-#elif defined(_ARM64_)
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, &contextPointers->X22);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, &contextPointers->X23);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, &contextPointers->X24);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, &contextPointers->X25);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, &contextPointers->X26);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, &contextPointers->X27);
-    GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, &contextPointers->X28);
-#else
-#error unsupported architecture
-#endif
-}
-
-BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers)
-{
-    int st;
-    unw_context_t unwContext;
-    unw_cursor_t cursor;
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_ARM64_)
-    DWORD64 curPc;
-#endif
-
-    if ((context->ContextFlags & CONTEXT_EXCEPTION_ACTIVE) != 0)
-    {
-        // The current frame is a source of hardware exception. Due to the fact that
-        // we use the low level unwinder to unwind just one frame a time, the
-        // unwinder doesn't have the signal_frame flag set. So it doesn't
-        // know that it should not decrement the PC before looking up the unwind info.
-        // So we compensate it by incrementing the PC before passing it to the unwinder.
-        // Without it, the unwinder would not find unwind info if the hardware exception
-        // happened in the first instruction of a function.
-        CONTEXTSetPC(context, CONTEXTGetPC(context) + 1);
-    }
-
-#if UNWIND_CONTEXT_IS_UCONTEXT_T
-    WinContextToUnwindContext(context, &unwContext);
-#else
-    st = unw_getcontext(&unwContext);
-    if (st < 0)
-    {
-        return FALSE;
-    }
-#endif
-    st = unw_init_local(&cursor, &unwContext);
-    if (st < 0)
-    {
-        return FALSE;
-    }
-
-#if !UNWIND_CONTEXT_IS_UCONTEXT_T
-    // Set the unwind context to the specified windows context
-    WinContextToUnwindCursor(context, &cursor);
-#endif
-
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_ARM64_)
-    // OSX and FreeBSD appear to do two different things when unwinding
-    // 1: If it reaches where it cannot unwind anymore, say a
-    // managed frame.  It wil return 0, but also update the $pc
-    // 2: If it unwinds all the way to _start it will return
-    // 0 from the step, but $pc will stay the same.
-    // The behaviour of libunwind from nongnu.org is to null the PC
-    // So we bank the original PC here, so we can compare it after
-    // the step
-    curPc = CONTEXTGetPC(context);
-#endif
-
-    st = unw_step(&cursor);
-    if (st < 0)
-    {
-        return FALSE;
-    }
-
-    // Check if the frame we have unwound to is a frame that caused
-    // synchronous signal, like a hardware exception and record it
-    // in the context flags.
-    if (unw_is_signal_frame(&cursor) > 0)
-    {
-        context->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE;
-    }
-    else
-    {
-        context->ContextFlags &= ~CONTEXT_EXCEPTION_ACTIVE;
-    }
-
-    // Update the passed in windows context to reflect the unwind
-    //
-    UnwindContextToWinContext(&cursor, context);
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_ARM64_)
-    if (st == 0 && CONTEXTGetPC(context) == curPc)
-    {
-        CONTEXTSetPC(context, 0);
-    }
-#endif
-
-    if (contextPointers != NULL)
-    {
-        GetContextPointers(&cursor, &unwContext, contextPointers);
-    }
-    return TRUE;
-}
-#else // __i686__
-BOOL PAL_VirtualUnwind(CONTEXT *context, void *contextPointers)
-{
-    return FALSE;
-}
-#endif
-
-#else
-#error don't know how to unwind on this platform
-#endif
-
-// These methods are only used on the AMD64 build
-#ifdef _AMD64_
-#ifdef __LINUX__
-
-static struct LibunwindCallbacksInfoType
-{
-     CONTEXT *Context;
-     ReadMemoryWordCallback readMemCallback;
-} LibunwindCallbacksInfo;
-
-static int get_dyn_info_list_addr(unw_addr_space_t as, unw_word_t *dilap, void *arg)
-{
-    return -UNW_ENOINFO;
-}
-
-static int access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, int write, void *arg)
-{
-    if (write)
-    {
-        ASSERT("Memory write must never be called by libunwind during stackwalk");
-        return -UNW_EINVAL;
-    }
-
-    // access_mem sometimes gets called by _UPT_find_proc_info, in such cases arg has a pointer to libunwind internal data
-    // returned by _UPT_create. It makes it impossible to use arg for passing readMemCallback. That's why we have to use global variable.
-    if (LibunwindCallbacksInfo.readMemCallback((SIZE_T)addr, (SIZE_T *)valp))
-    {
-        return UNW_ESUCCESS;
-    }
-    else
-    {
-        return -UNW_EUNSPEC;
-    }
-}
-
-static int access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write, void *arg)
-{
-    if (write)
-    {
-        ASSERT("Register write must never be called by libunwind during stackwalk");
-        return -UNW_EREADONLYREG;
-    }
-
-    CONTEXT *winContext = LibunwindCallbacksInfo.Context;
-
-    switch (regnum)
-    {
-#if defined(_AMD64_)
-        case UNW_REG_IP:       *valp = (unw_word_t) winContext->Rip; break;
-        case UNW_REG_SP:       *valp = (unw_word_t) winContext->Rsp; break;
-        case UNW_X86_64_RBP:   *valp = (unw_word_t) winContext->Rbp; break;
-        case UNW_X86_64_RBX:   *valp = (unw_word_t) winContext->Rbx; break;
-        case UNW_X86_64_R12:   *valp = (unw_word_t) winContext->R12; break;
-        case UNW_X86_64_R13:   *valp = (unw_word_t) winContext->R13; break;
-        case UNW_X86_64_R14:   *valp = (unw_word_t) winContext->R14; break;
-        case UNW_X86_64_R15:   *valp = (unw_word_t) winContext->R15; break;
-#elif defined(_ARM_)
-        case UNW_ARM_R13:      *valp = (unw_word_t) winContext->Sp; break;
-        case UNW_ARM_R14:      *valp = (unw_word_t) winContext->Lr; break;
-        case UNW_ARM_R15:      *valp = (unw_word_t) winContext->Pc; break;
-        case UNW_ARM_R4:       *valp = (unw_word_t) winContext->R4; break;
-        case UNW_ARM_R5:       *valp = (unw_word_t) winContext->R5; break;
-        case UNW_ARM_R6:       *valp = (unw_word_t) winContext->R6; break;
-        case UNW_ARM_R7:       *valp = (unw_word_t) winContext->R7; break;
-        case UNW_ARM_R8:       *valp = (unw_word_t) winContext->R8; break;
-        case UNW_ARM_R9:       *valp = (unw_word_t) winContext->R9; break;
-        case UNW_ARM_R10:      *valp = (unw_word_t) winContext->R10; break;
-        case UNW_ARM_R11:      *valp = (unw_word_t) winContext->R11; break;
-#elif defined(_ARM64_)
-        case UNW_REG_IP:       *valp = (unw_word_t) winContext->Pc; break;
-        case UNW_REG_SP:       *valp = (unw_word_t) winContext->Sp; break;
-        case UNW_AARCH64_X29:  *valp = (unw_word_t) winContext->Fp; break;
-        case UNW_AARCH64_X30:  *valp = (unw_word_t) winContext->Lr; break;
-        case UNW_AARCH64_X19:  *valp = (unw_word_t) winContext->X19; break;
-        case UNW_AARCH64_X20:  *valp = (unw_word_t) winContext->X20; break;
-        case UNW_AARCH64_X21:  *valp = (unw_word_t) winContext->X21; break;
-        case UNW_AARCH64_X22:  *valp = (unw_word_t) winContext->X22; break;
-        case UNW_AARCH64_X23:  *valp = (unw_word_t) winContext->X23; break;
-        case UNW_AARCH64_X24:  *valp = (unw_word_t) winContext->X24; break;
-        case UNW_AARCH64_X25:  *valp = (unw_word_t) winContext->X25; break;
-        case UNW_AARCH64_X26:  *valp = (unw_word_t) winContext->X26; break;
-        case UNW_AARCH64_X27:  *valp = (unw_word_t) winContext->X27; break;
-        case UNW_AARCH64_X28:  *valp = (unw_word_t) winContext->X28; break;
-#else
-#error unsupported architecture
-#endif
-        default:
-            ASSERT("Attempt to read an unknown register.");
-            return -UNW_EBADREG;
-    }
-    return UNW_ESUCCESS;
-}
-
-static int access_fpreg(unw_addr_space_t as, unw_regnum_t regnum, unw_fpreg_t *fpvalp, int write, void *arg)
-{
-    ASSERT("Not supposed to be ever called");
-    return -UNW_EINVAL;
-}
-
-static int resume(unw_addr_space_t as, unw_cursor_t *cp, void *arg)
-{
-    ASSERT("Not supposed to be ever called");
-    return -UNW_EINVAL;
-}
-
-static int get_proc_name(unw_addr_space_t as, unw_word_t addr, char *bufp, size_t buf_len, unw_word_t *offp, void *arg)
-{
-    ASSERT("Not supposed to be ever called");
-    return -UNW_EINVAL;
-}
-
-int find_proc_info(unw_addr_space_t as,
-                   unw_word_t ip, unw_proc_info_t *pip,
-                   int need_unwind_info, void *arg)
-{
-#ifdef HAVE_LIBUNWIND_PTRACE
-    // UNIXTODO: libunwind RPM package on Fedora/CentOS/RedHat doesn't have libunwind-ptrace.so
-    // and we can't use it from a shared library like libmscordaccore.so.
-    // That's why all calls to ptrace parts of libunwind ifdeffed out for now.
-    return _UPT_find_proc_info(as, ip, pip, need_unwind_info, arg);
-#else
-    return -UNW_EINVAL;
-#endif
-}
-
-void put_unwind_info(unw_addr_space_t as, unw_proc_info_t *pip, void *arg)
-{
-#ifdef HAVE_LIBUNWIND_PTRACE
-    return _UPT_put_unwind_info(as, pip, arg);
-#endif
-}
-
-static unw_accessors_t unwind_accessors =
-{
-    .find_proc_info = find_proc_info,
-    .put_unwind_info = put_unwind_info,
-    .get_dyn_info_list_addr = get_dyn_info_list_addr,
-    .access_mem = access_mem,
-    .access_reg = access_reg,
-    .access_fpreg = access_fpreg,
-    .resume = resume,
-    .get_proc_name = get_proc_name
-};
-
-BOOL PAL_VirtualUnwindOutOfProc(CONTEXT *context,
-                                KNONVOLATILE_CONTEXT_POINTERS *contextPointers,
-                                DWORD pid,
-                                ReadMemoryWordCallback readMemCallback)
-{
-    // This function can be executed only by one thread at a time.
-    // The reason for this is that we need to pass context and read mem function to libunwind callbacks
-    // but "arg" is already used by the pointer returned from _UPT_create().
-    // So we resort to using global variables and a lock.
-    struct Lock
-    {
-        CRITICAL_SECTION cs;
-        Lock()
-        {
-            // ctor of a static variable is a thread-safe way to initialize critical section exactly once (clang,gcc)
-            InitializeCriticalSection(&cs);
-        }
-    };
-    struct LockHolder
-    {
-        CRITICAL_SECTION *cs;
-        LockHolder(CRITICAL_SECTION *cs)
-        {
-            this->cs = cs;
-            EnterCriticalSection(cs);
-        }
-
-        ~LockHolder()
-        {
-            LeaveCriticalSection(cs);
-            cs = NULL;
-        }
-    };
-    static Lock lock;
-    LockHolder lockHolder(&lock.cs);
-
-    int st;
-    unw_context_t unwContext;
-    unw_cursor_t cursor;
-    unw_addr_space_t addrSpace = 0;
-    void *libunwindUptPtr = NULL;
-    BOOL result = FALSE;
-
-    LibunwindCallbacksInfo.Context = context;
-    LibunwindCallbacksInfo.readMemCallback = readMemCallback;
-    WinContextToUnwindContext(context, &unwContext);
-    addrSpace = unw_create_addr_space(&unwind_accessors, 0);
-#ifdef HAVE_LIBUNWIND_PTRACE
-    libunwindUptPtr = _UPT_create(pid);
-#endif
-    st = unw_init_remote(&cursor, addrSpace, libunwindUptPtr);
-    if (st < 0)
-    {
-        result = FALSE;
-        goto Exit;
-    }
-
-    st = unw_step(&cursor);
-    if (st < 0)
-    {
-        result = FALSE;
-        goto Exit;
-    }
-
-    UnwindContextToWinContext(&cursor, context);
-
-    if (contextPointers != NULL)
-    {
-        GetContextPointers(&cursor, &unwContext, contextPointers);
-    }
-    result = TRUE;
-
-Exit:
-#ifdef HAVE_LIBUNWIND_PTRACE
-    if (libunwindUptPtr != NULL)
-    {
-        _UPT_destroy(libunwindUptPtr);
-    }
-#endif
-    if (addrSpace != 0)
-    {
-        unw_destroy_addr_space(addrSpace);
-    }
-    return result;
-}
-#else // __LINUX__
-
-BOOL PAL_VirtualUnwindOutOfProc(CONTEXT *context,
-                                KNONVOLATILE_CONTEXT_POINTERS *contextPointers,
-                                DWORD pid,
-                                ReadMemoryWordCallback readMemCallback)
-{
-    //UNIXTODO: Implement for Mac flavor of libunwind
-    return FALSE;
-}
-
-#endif // !__LINUX__
-#endif // _AMD64_
-
-/*++
-Function:
-    RtlpRaiseException
-
-Parameters:
-    ExceptionRecord - the Windows exception record to throw
-
-Note:
-    The name of this function and the name of the ExceptionRecord
-    parameter is used in the sos lldb plugin code to read the exception
-    record. See coreclr\src\ToolBox\SOS\lldbplugin\debugclient.cpp.
-
-    This function must not be inlined or optimized so the below PAL_VirtualUnwind
-    calls end up with RaiseException caller's context and so the above debugger
-    code finds the function and ExceptionRecord parameter.
---*/
-PAL_NORETURN
-__attribute__((noinline))
-__attribute__((optnone))
-static void
-RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord)
-{
-    // Capture the context of RtlpRaiseException.
-    CONTEXT ContextRecord;
-    ZeroMemory(&ContextRecord, sizeof(CONTEXT));
-    ContextRecord.ContextFlags = CONTEXT_FULL;
-    CONTEXT_CaptureContext(&ContextRecord);
-
-    // Find the caller of RtlpRaiseException.
-    PAL_VirtualUnwind(&ContextRecord, NULL);
-
-    // The frame we're looking at now is RaiseException. We have to unwind one
-    // level further to get the actual context user code could be resumed at.
-    PAL_VirtualUnwind(&ContextRecord, NULL);
-
-#if defined(_X86_)
-    ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Eip;
-#elif defined(_AMD64_)
-    ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Rip;
-#elif defined(_ARM_) || defined(_ARM64_)
-    ExceptionRecord->ExceptionAddress = (void *) ContextRecord.Pc;
-#else
-#error unsupported architecture
-#endif
-
-    throw PAL_SEHException(ExceptionRecord, &ContextRecord);
-}
-
-/*++
-Function:
-  RaiseException
-
-See MSDN doc.
---*/
-// no PAL_NORETURN, as callers must assume this can return for continuable exceptions.
-VOID
-PALAPI
-RaiseException(IN DWORD dwExceptionCode,
-               IN DWORD dwExceptionFlags,
-               IN DWORD nNumberOfArguments,
-               IN CONST ULONG_PTR *lpArguments)
-{
-    // PERF_ENTRY_ONLY is used here because RaiseException may or may not
-    // return. We can not get latency data without PERF_EXIT. For this reason,
-    // PERF_ENTRY_ONLY is used to profile frequency only.
-    PERF_ENTRY_ONLY(RaiseException);
-    ENTRY("RaiseException(dwCode=%#x, dwFlags=%#x, nArgs=%u, lpArguments=%p)\n",
-          dwExceptionCode, dwExceptionFlags, nNumberOfArguments, lpArguments);
-
-    /* Validate parameters */
-    if (dwExceptionCode & RESERVED_SEH_BIT)
-    {
-        WARN("Exception code %08x has bit 28 set; clearing it.\n", dwExceptionCode);
-        dwExceptionCode ^= RESERVED_SEH_BIT;
-    }
-
-    if (nNumberOfArguments > EXCEPTION_MAXIMUM_PARAMETERS)
-    {
-        WARN("Number of arguments (%d) exceeds the limit "
-            "EXCEPTION_MAXIMUM_PARAMETERS (%d); ignoring extra parameters.\n",
-            nNumberOfArguments, EXCEPTION_MAXIMUM_PARAMETERS);
-        nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS;
-    }
-
-    EXCEPTION_RECORD exceptionRecord;
-    ZeroMemory(&exceptionRecord, sizeof(EXCEPTION_RECORD));
-
-    exceptionRecord.ExceptionCode = dwExceptionCode;
-    exceptionRecord.ExceptionFlags = dwExceptionFlags;
-    exceptionRecord.ExceptionRecord = NULL;
-    exceptionRecord.ExceptionAddress = NULL; // will be set by RtlpRaiseException
-    exceptionRecord.NumberParameters = nNumberOfArguments;
-    if (nNumberOfArguments)
-    {
-        CopyMemory(exceptionRecord.ExceptionInformation, lpArguments,
-                   nNumberOfArguments * sizeof(ULONG_PTR));
-    }
-    RtlpRaiseException(&exceptionRecord);
-
-    LOGEXIT("RaiseException returns\n");
-}

+ 11 - 299
pal/src/exception/seh.cpp

@@ -1,308 +1,20 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
-//
-
-/*++
-
-
-
-Module Name:
-
-    seh.cpp
-
-Abstract:
-
-    Implementation of exception API functions.
-
-
-
---*/
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
 
 #include "pal/thread.hpp"
 #include "pal/handleapi.hpp"
-#include "pal/seh.hpp"
-#include "pal/dbgmsg.h"
-#include "pal/critsect.h"
-#include "pal/debug.h"
-#include "pal/init.h"
-#include "pal/process.h"
-#include "pal/malloc.hpp"
-#include "signal.hpp"
-
-#if HAVE_ALLOCA_H
-#include "alloca.h"
-#endif
-
-#if HAVE_MACH_EXCEPTIONS
-#include "machexception.h"
-#else
-#include <signal.h>
-#endif
-
-#include <string.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <stdlib.h>
-
-using namespace CorUnix;
-
-SET_DEFAULT_DEBUG_CHANNEL(EXCEPT);
-
-/* Constant and type definitions **********************************************/
-
-/* Bit 28 of exception codes is reserved. */
-const UINT RESERVED_SEH_BIT = 0x800000;
-
-/* Internal variables definitions **********************************************/
-
-PHARDWARE_EXCEPTION_HANDLER g_hardwareExceptionHandler = NULL;
-
-/* Internal function definitions **********************************************/
-
-/*++
-Function :
-    SEHInitialize
-
-    Initialize all SEH-related stuff (signals, etc)
-
-Parameters :
-    CPalThread * pthrCurrent : reference to the current thread.
-    PAL initialize flags
-
-Return value :
-    TRUE  if SEH support initialization succeeded
-    FALSE otherwise
---*/
-BOOL 
-SEHInitialize (CPalThread *pthrCurrent, DWORD flags)
-{
-#if !HAVE_MACH_EXCEPTIONS
-    if (!SEHInitializeSignals())
-    {
-        ERROR("SEHInitializeSignals failed!\n");
-        SEHCleanup();
-        return FALSE;
-    }
-#endif
-
-    return TRUE;
-}
-
-/*++
-Function :
-    SEHCleanup
-
-    Undo work done by SEHInitialize
-
-Parameters :
-    None
-
-    (no return value)
-    
---*/
-VOID 
-SEHCleanup()
-{
-    TRACE("Cleaning up SEH\n");
-
-#if HAVE_MACH_EXCEPTIONS
-    SEHCleanupExceptionPort();
-#else
-    SEHCleanupSignals();
-#endif
-}
 
-/*++
-Function:
-    PAL_SetHardwareExceptionHandler
-
-    Register a hardware exception handler.
-
-Parameters:
-    handler - exception handler
-
-Return value:
-    None
---*/
-VOID
-PALAPI 
-PAL_SetHardwareExceptionHandler(
-    IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler)
-{
-    g_hardwareExceptionHandler = exceptionHandler;
-}
-
-/*++
-Function:
-    SEHProcessException
-
-    Build the PAL exception and sent it to any handler registered.
-
-Parameters:
-    PEXCEPTION_POINTERS pointers
-
-Return value:
-    Returns only if the exception is unhandled
---*/
 VOID
-SEHProcessException(PEXCEPTION_POINTERS pointers)
-{
-    if (!IsInDebugBreak(pointers->ExceptionRecord->ExceptionAddress))
-    {
-        PAL_SEHException exception(pointers->ExceptionRecord, pointers->ContextRecord);
-
-        if (g_hardwareExceptionHandler != NULL)
-        {
-            g_hardwareExceptionHandler(&exception);
-        }
-
-        if (CatchHardwareExceptionHolder::IsEnabled())
-        {
-            throw exception;
-        }
-    }
-
-    TRACE("Unhandled hardware exception %08x at %p\n", 
-        pointers->ExceptionRecord->ExceptionCode, pointers->ExceptionRecord->ExceptionAddress);
-}
-
-/*++
-Function :
-    SEHEnable
-
-    Enable SEH-related stuff on this thread
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-
-Return value :
-    TRUE  if enabling succeeded
-    FALSE otherwise
---*/
-extern "C"
-PAL_ERROR SEHEnable(CPalThread *pthrCurrent)
-{
-#if HAVE_MACH_EXCEPTIONS
-    return pthrCurrent->EnableMachExceptions();
-#elif __LINUX__ || defined(__FreeBSD__)
-    // TODO: This needs to be implemented. Cannot put an ASSERT here
-    // because it will make other parts of PAL fail.
-    return NO_ERROR;
-#else// HAVE_MACH_EXCEPTIONS
-#error not yet implemented
-#endif // HAVE_MACH_EXCEPTIONS
-}
-
-/*++
-Function :
-    SEHDisable
-
-    Disable SEH-related stuff on this thread
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-
-Return value :
-    TRUE  if enabling succeeded
-    FALSE otherwise
---*/
-extern "C"
-PAL_ERROR SEHDisable(CPalThread *pthrCurrent)
-{
-#if HAVE_MACH_EXCEPTIONS
-    return pthrCurrent->DisableMachExceptions();
-    // TODO: This needs to be implemented. Cannot put an ASSERT here
-    // because it will make other parts of PAL fail.
-#elif __LINUX__ || defined(__FreeBSD__)
-    return NO_ERROR;
-#else // HAVE_MACH_EXCEPTIONS
-#error not yet implemented
-#endif // HAVE_MACH_EXCEPTIONS
-}
-
-/*++
-
-  CatchHardwareExceptionHolder implementation
-
---*/
-
-CatchHardwareExceptionHolder::CatchHardwareExceptionHolder()
-{
-    CPalThread *pThread = InternalGetCurrentThread();
-    ++pThread->m_hardwareExceptionHolderCount;
-}
-
-CatchHardwareExceptionHolder::~CatchHardwareExceptionHolder()
+PALAPI
+RaiseException(IN DWORD dwExceptionCode,
+               IN DWORD dwExceptionFlags,
+               IN DWORD nNumberOfArguments,
+               IN CONST ULONG_PTR *lpArguments)
 {
-    CPalThread *pThread = InternalGetCurrentThread();
-    --pThread->m_hardwareExceptionHolderCount;
-}
-
-bool CatchHardwareExceptionHolder::IsEnabled()
-{
-    CPalThread *pThread = InternalGetCurrentThread();
-    return pThread->IsHardwareExceptionsEnabled();
-}
-
-/*++
-
-  NativeExceptionHolderBase implementation
-
---*/
-
-#ifndef __IOS__
-// todo: Implement ThreadLocal for iOS ?? i.e. pthread get/set specific ??
-#ifdef __llvm__
-__thread 
-#else // __llvm__
-__declspec(thread)
-#endif // !__llvm__
-#endif
-static NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr;
-
-NativeExceptionHolderBase::NativeExceptionHolderBase()
-{
-    m_head = nullptr;
-    m_next = nullptr;
-}
-
-NativeExceptionHolderBase::~NativeExceptionHolderBase()
-{
-    // Only destroy if Push was called
-    if (m_head != nullptr)
-    {
-        *m_head = m_next;
-        m_head = nullptr;
-        m_next = nullptr;
-    }
-}
-
-void 
-NativeExceptionHolderBase::Push()
-{
-    NativeExceptionHolderBase **head = &t_nativeExceptionHolderHead;
-    m_head = head;
-    m_next = *head;
-    *head = this;
-}
-
-NativeExceptionHolderBase *
-NativeExceptionHolderBase::FindNextHolder(NativeExceptionHolderBase *currentHolder, void *stackLowAddress, void *stackHighAddress)
-{
-    NativeExceptionHolderBase *holder = (currentHolder == nullptr) ? t_nativeExceptionHolderHead : currentHolder->m_next;
-
-    while (holder != nullptr)
+    if (dwExceptionCode == DBG_TERMINATE_PROCESS || dwExceptionFlags & EXCEPTION_NONCONTINUABLE)
     {
-        if (((void *)holder > stackLowAddress) && ((void *)holder < stackHighAddress))
-        { 
-            return holder;
-        }
-        // Get next holder
-        holder = holder->m_next;
+        abort();
     }
-
-    return nullptr;
 }
-
-#include "seh-unwind.cpp"

+ 21 - 20
pal/src/exception/signal.cpp

@@ -1,6 +1,6 @@
 //
 // Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
 /*++
@@ -24,7 +24,6 @@ Abstract:
 #include "pal/thread.hpp"
 #include "pal/threadinfo.hpp"
 #include "pal/threadsusp.hpp"
-#include "pal/seh.hpp"
 
 #include "pal/palinternal.h"
 #if !HAVE_MACH_EXCEPTIONS
@@ -66,7 +65,7 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context);
 static void sigtrap_handler(int code, siginfo_t *siginfo, void *context);
 static void sigbus_handler(int code, siginfo_t *siginfo, void *context);
 
-static void common_signal_handler(PEXCEPTION_POINTERS pointers, int code, 
+static void common_signal_handler(PEXCEPTION_POINTERS pointers, int code,
                                   native_context_t *ucontext);
 
 static void inject_activation_handler(int code, siginfo_t *siginfo, void *context);
@@ -145,11 +144,11 @@ Parameters :
     None
 
     (no return value)
-    
+
 note :
-reason for this function is that during PAL_Terminate, we reach a point where 
-SEH isn't possible anymore (handle manager is off, etc). Past that point, 
-we can't avoid crashing on a signal     
+reason for this function is that during PAL_Terminate, we reach a point where
+SEH isn't possible anymore (handle manager is off, etc). Past that point,
+we can't avoid crashing on a signal
 --*/
 void SEHCleanupSignals()
 {
@@ -431,8 +430,8 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex
 
             CONTEXT winContext;
             CONTEXTFromNativeContext(
-                ucontext, 
-                &winContext, 
+                ucontext,
+                &winContext,
                 CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT);
 
             if (g_safeActivationCheckFunction(CONTEXTGetPC(&winContext), true))
@@ -454,7 +453,7 @@ Function :
 
 Parameters :
     pThread            - target PAL thread
-    activationFunction - function to call 
+    activationFunction - function to call
 
 (no return value)
 --*/
@@ -464,7 +463,7 @@ PAL_ERROR InjectActivationInternal(CorUnix::CPalThread* pThread)
     if (status != 0)
     {
         // Failure to send the signal is fatal. There are only two cases when sending
-        // the signal can fail. First, if the signal ID is invalid and second, 
+        // the signal can fail. First, if the signal ID is invalid and second,
         // if the thread doesn't exist anymore.
         abort();
     }
@@ -476,7 +475,7 @@ PAL_ERROR InjectActivationInternal(CorUnix::CPalThread* pThread)
 Function :
     SEHSetSafeState
 
-    specify whether the current thread is in a state where exception handling 
+    specify whether the current thread is in a state where exception handling
     of signals can be done safely
 
 Parameters:
@@ -498,7 +497,7 @@ void SEHSetSafeState(CPalThread *pthrCurrent, BOOL state)
 Function :
     SEHGetSafeState
 
-    determine whether the current thread is in a state where exception handling 
+    determine whether the current thread is in a state where exception handling
     of signals can be done safely
 
     (no parameters)
@@ -529,10 +528,10 @@ Parameters :
 
     (no return value)
 Note:
-    the "pointers" parameter should contain a valid exception record pointer, 
-    but the contextrecord pointer will be overwritten.    
+    the "pointers" parameter should contain a valid exception record pointer,
+    but the contextrecord pointer will be overwritten.
 --*/
-static void common_signal_handler(PEXCEPTION_POINTERS pointers, int code, 
+static void common_signal_handler(PEXCEPTION_POINTERS pointers, int code,
                                   native_context_t *ucontext)
 {
     sigset_t signal_set;
@@ -555,9 +554,11 @@ static void common_signal_handler(PEXCEPTION_POINTERS pointers, int code,
     if(-1 == sigprocmask(SIG_UNBLOCK, &signal_set, NULL))
     {
         ASSERT("sigprocmask failed; error is %d (%s)\n", errno, strerror(errno));
-    } 
+    }
 
-    SEHProcessException(pointers);
+    // We do nothing further
+    // xplat-todo : investigate further cleanup
+    // SEHProcessException(pointers);
 }
 
 /*++
@@ -572,8 +573,8 @@ Parameters :
     previousAction : previous sigaction struct
 
     (no return value)
-    
-note : if sigfunc is NULL, the default signal handler is restored    
+
+note : if sigfunc is NULL, the default signal handler is restored
 --*/
 void handle_signal(int signal_id, SIGFUNC sigfunc, struct sigaction *previousAction)
 {

+ 0 - 171
pal/src/include/pal/seh.hpp

@@ -1,171 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
-//
-
-/*++
-
-
-
-Module Name:
-
-    include/pal/seh.hpp
-
-Abstract:
-    Header file for public Structured Exception Handling stuff
-
-
-
---*/
-
-#ifndef _PAL_SEH_HPP_
-#define _PAL_SEH_HPP_
-
-#include "config.h"
-#include "pal/palinternal.h"
-#include "pal/corunix.hpp"
-
-#define DO_NOT_USE_SIGNAL_HANDLING_THREAD
-
-/*++
-Function :
-    SEHInitialize
-
-    Initialize all SEH-related stuff (signals, etc)
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-    flags : PAL initialize flags
-
-Return value:
-    TRUE  if SEH support initialization succeeded,
-    FALSE otherwise
-
---*/
-BOOL 
-SEHInitialize(CorUnix::CPalThread *pthrCurrent, DWORD flags);
-
-/*++
-Function :
-    SEHCleanup
-
-    Clean up SEH-related stuff(signals, etc)
-
-Parameters:
-    None
-
-    (no return value)
---*/
-VOID 
-SEHCleanup();
-
-/*++
-Function:
-    SEHProcessException
-
-    Build the PAL exception and sent it to any handler registered.
-
-Parameters:
-    None
-
-Return value:
-    Does not return
---*/
-VOID 
-SEHProcessException(PEXCEPTION_POINTERS pointers);
-
-#if !HAVE_MACH_EXCEPTIONS
-// TODO: Implement for Mach exceptions.  Not in CoreCLR surface area.
-/*++
-Function :
-    SEHHandleControlEvent
-
-    handle Control-C and Control-Break events (call handler routines, 
-    notify debugger)
-
-Parameters :
-    DWORD event : event that occurred
-    LPVOID eip  : instruction pointer when exception occurred                                 
-
-(no return value)
-
-Notes :
-    Handlers are called on a last-installed, first called basis, until a 
-    handler returns TRUE. If no handler returns TRUE (or no hanlder is 
-    installed), the default behavior is to call ExitProcess
---*/
-void SEHHandleControlEvent(DWORD event, LPVOID eip);
-#endif // !HAVE_MACH_EXCEPTIONS
-
-#if !HAVE_MACH_EXCEPTIONS
-/*++
-Function :
-    SEHSetSafeState
-
-    specify whether the current thread is in a state where exception handling 
-    of signals can be done safely
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-    BOOL state : TRUE if the thread is safe, FALSE otherwise
-
-(no return value)
---*/
-void SEHSetSafeState(CorUnix::CPalThread *pthrCurrent, BOOL state);
-
-/*++
-Function :
-    SEHGetSafeState
-
-    determine whether the current thread is in a state where exception handling 
-    of signals can be done safely
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-
-Return value :
-    TRUE if the thread is in a safe state, FALSE otherwise
---*/
-BOOL SEHGetSafeState(CorUnix::CPalThread *pthrCurrent);
-#endif // !HAVE_MACH_EXCEPTIONS
-
-extern "C"
-{
-
-#ifdef FEATURE_PAL_SXS
-/*++
-Function :
-    SEHEnable
-
-    Enable SEH-related stuff on this thread
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-
-Return value :
-    ERROR_SUCCESS, if enabling succeeded
-    an error code, otherwise
---*/
-CorUnix::PAL_ERROR SEHEnable(CorUnix::CPalThread *pthrCurrent);
-
-/*++
-Function :
-    SEHDisable
-
-    Disable SEH-related stuff on this thread
-
-Parameters:
-    CPalThread * pthrCurrent : reference to the current thread.
-
-Return value :
-    ERROR_SUCCESS, if enabling succeeded
-    an error code, otherwise
---*/
-CorUnix::PAL_ERROR SEHDisable(CorUnix::CPalThread *pthrCurrent);
-
-#endif // FEATURE_PAL_SXS
-
-}
-
-#endif /* _PAL_SEH_HPP_ */
-

+ 0 - 2
pal/src/include/pal/thread.hpp

@@ -283,8 +283,6 @@ namespace CorUnix
                 HANDLE *phThread
                 );
 
-        friend CatchHardwareExceptionHolder;
-
     private:
 
         CPalThread *m_pNext;

+ 9 - 9
pal/src/init/pal.cpp

@@ -26,7 +26,6 @@ Abstract:
 #include "pal/file.hpp"
 #include "pal/map.hpp"
 #include "../objmgr/shmobjectmanager.hpp"
-#include "pal/seh.hpp"
 #include "pal/palinternal.h"
 #include "pal/dbgmsg.h"
 #include "pal/shmemory.h"
@@ -42,6 +41,8 @@ Abstract:
 
 #if HAVE_MACH_EXCEPTIONS
 #include "../exception/machexception.h"
+#else
+#include "../exception/signal.hpp"
 #endif
 
 #include <stdlib.h>
@@ -441,6 +442,13 @@ Initialize(
             goto CLEANUP2;
         }
 
+#if !HAVE_MACH_EXCEPTIONS
+        if(!SEHInitializeSignals())
+        {
+            goto CLEANUP5;
+        }
+#endif
+
         if (flags & PAL_INITIALIZE_SYNC_THREAD)
         {
             //
@@ -456,13 +464,6 @@ Initialize(
 
         palError = ERROR_GEN_FAILURE;
 
-        /* initialize structured exception handling stuff (signals, etc) */
-        if (FALSE == SEHInitialize(pThread, flags))
-        {
-            ERROR("Unable to initialize SEH support\n");
-            goto CLEANUP5;
-        }
-
         if (FALSE == TIMEInitialize())
         {
             ERROR("Unable to initialize TIME support\n");
@@ -530,7 +531,6 @@ CLEANUP13:
 CLEANUP10:
     MAPCleanup();
 CLEANUP6:
-    SEHCleanup();
 CLEANUP5:
     PROCCleanupInitialProcess();
 CLEANUP2:

+ 11 - 12
pal/src/init/sxs.cpp

@@ -1,6 +1,6 @@
 //
 // Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
 /*++
@@ -15,7 +15,6 @@
 #include "pal/thread.hpp"
 #include "../thread/procprivate.hpp"
 #include "pal/module.h"
-#include "pal/seh.hpp"
 
 using namespace CorUnix;
 
@@ -56,12 +55,12 @@ PAL_Enter(PAL_Boundary boundary)
     }
     else
     {
-        // If this assert fires, we'll have to pipe this information so that 
-        // CPalThread's RunPostCreateInitializers call to SEHEnable 
+        // If this assert fires, we'll have to pipe this information so that
+        // CPalThread's RunPostCreateInitializers call to SEHEnable
         // can know what direction.
         _ASSERT_MSG(PAL_BoundaryTop == boundary, "How are we entering a PAL "
             "thread for the first time not from the top? (boundary=%u)", boundary);
-            
+
         palError = AllocatePalThread(&pThread);
         if (NO_ERROR != palError)
         {
@@ -78,9 +77,9 @@ Function:
   CreateCurrentThreadData
 
 Abstract:
-  This function is called by the InternalGetOrCreateCurrentThread inlined 
+  This function is called by the InternalGetOrCreateCurrentThread inlined
   function to create the thread data when it is null meaning the thread has
-  never been in this PAL. 
+  never been in this PAL.
 
 Warning:
   If the allocation fails, this function asserts and exits the process.
@@ -121,9 +120,9 @@ AllocatePalThread(CPalThread **ppThread)
         pThread->ReleaseThreadReference();
         goto exit;
     }
-    
-    // Like CreateInitialProcessAndThreadObjects, we do not need this 
-    // thread handle, since we're not returning it to anyone who will 
+
+    // Like CreateInitialProcessAndThreadObjects, we do not need this
+    // thread handle, since we're not returning it to anyone who will
     // possibly release it.
     (void)g_pObjectManager->RevokeHandle(pThread, hThread);
 
@@ -195,7 +194,7 @@ PAL_HasEntered()
     }
 
     LOGEXIT("PAL_HasEntered returned\n");
-    
+
     return pThread->IsInPal();
 }
 
@@ -278,7 +277,7 @@ PALAPI
 PAL_Leave(PAL_Boundary boundary)
 {
     ENTRY("PAL_Leave(boundary=%u)\n", boundary);
-    
+
     CPalThread *pThread = GetCurrentPalThread();
     // We ignore the return code.  This call should only fail on internal
     // error, and we assert at the actual failure.

+ 3 - 9
pal/src/loader/module.cpp

@@ -1143,24 +1143,18 @@ static BOOL LOADCallDllMainSafe(MODSTRUCT *module, DWORD dwReason, LPVOID lpRese
     param.lpReserved = lpReserved;
     param.ret = FALSE;
 
-    PAL_TRY(Param *, pParam, &param)
     {
         TRACE("Calling DllMain (%p) for module %S\n",
-              pParam->module->pDllMain,
-              pParam->module->lib_name ? pParam->module->lib_name : W16_NULLSTRING);
+              param.module->pDllMain,
+              param.module->lib_name ? param.module->lib_name : W16_NULLSTRING);
 
         {
             // This module may be foreign to our PAL, so leave our PAL.
             // If it depends on us, it will re-enter.
             PAL_LeaveHolder holder;
-            pParam->ret = pParam->module->pDllMain(pParam->module->hinstance, pParam->dwReason, pParam->lpReserved);
+            param.ret = param.module->pDllMain(param.module->hinstance, param.dwReason, param.lpReserved);
         }
     }
-    PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-    {
-        WARN("Call to DllMain (%p) got an unhandled exception; ignoring.\n", module->pDllMain);
-    }
-    PAL_ENDTRY
 
 #if _ENABLE_DEBUG_MESSAGES_
     /* ...and set nesting level back to what it was */

+ 0 - 1
pal/src/map/virtual.cpp

@@ -23,7 +23,6 @@ Abstract:
 #include "pal/cs.hpp"
 #include "pal/malloc.hpp"
 #include "pal/file.hpp"
-#include "pal/seh.hpp"
 #include "pal/dbgmsg.h"
 #include "pal/virtual.h"
 #include "pal/map.h"

+ 0 - 12
pal/src/thread/pal_thread.cpp

@@ -9,7 +9,6 @@
 #include "pal/mutex.hpp"
 #include "pal/handlemgr.hpp"
 #include "pal/cs.hpp"
-#include "pal/seh.hpp"
 
 #include "procprivate.hpp"
 #include "pal/process.h"
@@ -1058,8 +1057,6 @@ CorUnix::InternalEndCurrentThread(
         PROCRemoveThread(pThread, pThread);
 
 #ifdef FEATURE_PAL_SXS
-        // Ensure that EH is disabled on the current thread
-        SEHDisable(pThread);
         PAL_Leave(PAL_BoundaryTop);
 #endif // FEATURE_PAL_SXS
 
@@ -2311,15 +2308,6 @@ CPalThread::RunPostCreateInitializers(
         goto RunPostCreateInitializersExit;
     }
 
-#ifdef FEATURE_PAL_SXS
-    _ASSERTE(m_fInPal);
-    palError = SEHEnable(this);
-    if (NO_ERROR != palError)
-    {
-        goto RunPostCreateInitializersExit;
-    }
-#endif // FEATURE_PAL_SXS
-
 RunPostCreateInitializersExit:
 
     return palError;

+ 64 - 65
pal/src/thread/threadsusp.cpp

@@ -1,6 +1,6 @@
 //
 // Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
 
@@ -25,7 +25,6 @@ Revision History:
 #include "pal/corunix.hpp"
 #include "pal/thread.hpp"
 #include "pal/mutex.hpp"
-#include "pal/seh.hpp"
 #include "pal/init.h"
 #include "pal/dbgmsg.h"
 
@@ -39,13 +38,13 @@ Revision History:
 
 #if defined(_AIX)
 // AIX requires explicit definition of the union semun (see semctl man page)
-union semun 
+union semun
 {
     int val;
     struct semid_ds * buf;
     unsigned short * array;
 };
-#endif 
+#endif
 
 using namespace CorUnix;
 
@@ -56,7 +55,7 @@ SET_DEFAULT_DEBUG_CHANNEL(THREAD);
    in suspended state in order to resume it. */
 CONST BYTE WAKEUPCODE=0x2A;
 
-// #define USE_GLOBAL_LOCK_FOR_SUSPENSION // Uncomment this define to use the global suspension lock. 
+// #define USE_GLOBAL_LOCK_FOR_SUSPENSION // Uncomment this define to use the global suspension lock.
 /* The global suspension lock can be used in place of each thread having its own
 suspension mutex or spinlock. The downside is that it restricts us to only
 performing one suspension or resumption in the PAL at a time. */
@@ -97,7 +96,7 @@ CThreadSuspensionInfo::InternalSuspendNewThreadFromData(
 
     BYTE resume_code = 0;
     ssize_t read_ret;
-    
+
     // Block until ResumeThread writes something to the pipe
     while ((read_ret = read(pipe_descs[0], &resume_code, sizeof(resume_code))) != sizeof(resume_code))
     {
@@ -163,7 +162,7 @@ ResumeThread(
     }
     else
     {
-        _ASSERT_MSG(dwSuspendCount != static_cast<DWORD>(-1), "InternalResumeThread returned success but dwSuspendCount did not change.\n");   
+        _ASSERT_MSG(dwSuspendCount != static_cast<DWORD>(-1), "InternalResumeThread returned success but dwSuspendCount did not change.\n");
     }
 
     LOGEXIT("ResumeThread returns DWORD %u\n", dwSuspendCount);
@@ -175,7 +174,7 @@ ResumeThread(
 Function:
   InternalResumeThread
 
-InternalResumeThread converts the handle of the target thread to a 
+InternalResumeThread converts the handle of the target thread to a
 CPalThread, and passes both the resumer and target thread references
 to InternalResumeThreadFromData. A reference to the suspend count from
 the resumption attempt is passed back to the caller of this function.
@@ -223,11 +222,11 @@ Function:
 InternalResumeThreadFromData resumes the target thread. First, the suspension
 mutexes of the threads are acquired. Next, there's a check to ensure that the
 target thread was actually suspended. Finally, the resume attempt is made
-and the suspension mutexes are released. The suspend count of the 
+and the suspension mutexes are released. The suspend count of the
 target thread is passed back to the caller of this function.
 
 Note that ReleaseSuspensionLock(s) is called before hitting ASSERTs in error
-paths. Currently, this seems unnecessary since asserting within 
+paths. Currently, this seems unnecessary since asserting within
 InternalResumeThreadFromData will not cause cleanup to occur. However,
 this may change since it would be preferable to perform cleanup. Thus, calls
 to release suspension locks remain in the error paths.
@@ -253,8 +252,8 @@ CThreadSuspensionInfo::InternalResumeThreadFromData(
     // Acquire suspension mutex
     AcquireSuspensionLocks(pthrResumer, pthrTarget);
 
-    // Check target thread's state to ensure it hasn't died. 
-    // Setting a thread's state to TS_DONE is protected by the 
+    // Check target thread's state to ensure it hasn't died.
+    // Setting a thread's state to TS_DONE is protected by the
     // target's suspension mutex.
     if (pthrTarget->synchronizationInfo.GetThreadState() == TS_DONE)
     {
@@ -277,7 +276,7 @@ CThreadSuspensionInfo::InternalResumeThreadFromData(
     // If there is a blocking pipe on this thread, resume it by writing the wake up code to that pipe.
     if (-1 != pthrTarget->suspensionInfo.GetBlockingPipe())
     {
-        // If write() is interrupted by a signal before writing data, 
+        // If write() is interrupted by a signal before writing data,
         // it returns -1 and sets errno to EINTR. In this case, we
         // attempt the write() again.
         writeAgain:
@@ -286,7 +285,7 @@ CThreadSuspensionInfo::InternalResumeThreadFromData(
         // The size of WAKEUPCODE is 1 byte. If write returns 0, we'll treat it as an error.
         if (sizeof(WAKEUPCODE) != nWrittenBytes)
         {
-            // If we are here during process creation, this is most likely caused by the target 
+            // If we are here during process creation, this is most likely caused by the target
             // process dying before reaching this point and thus breaking the pipe.
             if (nWrittenBytes == -1 && EPIPE == errno)
             {
@@ -312,7 +311,7 @@ CThreadSuspensionInfo::InternalResumeThreadFromData(
 
         // Reset blocking pipe to -1 since we're done using it.
         pthrTarget->suspensionInfo.SetBlockingPipe(-1);
-        
+
         ReleaseSuspensionLocks(pthrResumer, pthrTarget);
         goto InternalResumeThreadFromDataExit;
     }
@@ -337,14 +336,14 @@ Function:
   TryAcquireSuspensionLock
 
 TryAcquireSuspensionLock is a utility function that tries to acquire a thread's
-suspension mutex or spinlock. If it succeeds, the function returns TRUE. 
+suspension mutex or spinlock. If it succeeds, the function returns TRUE.
 Otherwise, it returns FALSE. This function is used in AcquireSuspensionLocks.
 Note that the global lock cannot be acquired in this function since it makes
 no sense to do so. A thread holding the global lock is the only thread that
 can perform suspend or resume operations so it doesn't need to acquire
 a second lock.
 --*/
-BOOL 
+BOOL
 CThreadSuspensionInfo::TryAcquireSuspensionLock(
     CPalThread* pthrTarget
     )
@@ -369,12 +368,12 @@ CThreadSuspensionInfo::TryAcquireSuspensionLock(
 Function:
   AcquireSuspensionLock
 
-AcquireSuspensionLock acquires a thread's suspension mutex or spinlock. 
-If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, it will acquire the global lock. 
+AcquireSuspensionLock acquires a thread's suspension mutex or spinlock.
+If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, it will acquire the global lock.
 A thread in this function blocks until it acquires
 its lock, unlike in TryAcquireSuspensionLock.
 --*/
-void 
+void
 CThreadSuspensionInfo::AcquireSuspensionLock(
     CPalThread* pthrCurrent
     )
@@ -405,10 +404,10 @@ Function:
   ReleaseSuspensionLock
 
 ReleaseSuspensionLock is a function that releases a thread's suspension mutex
-or spinlock. If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, 
+or spinlock. If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined,
 it will release the global lock.
 --*/
-void 
+void
 CThreadSuspensionInfo::ReleaseSuspensionLock(
     CPalThread* pthrCurrent
     )
@@ -419,17 +418,17 @@ CThreadSuspensionInfo::ReleaseSuspensionLock(
 }
 #else // USE_GLOBAL_LOCK_FOR_SUSPENSION
 {
-    #if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 
+    #if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX
     {
         SPINLOCKRelease(&pthrCurrent->suspensionInfo.m_nSpinlock);
     }
-    #else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 
+    #else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX
     {
         INDEBUG(int iPthreadError = )
         pthread_mutex_unlock(&pthrCurrent->suspensionInfo.m_ptmSuspmutex);
         _ASSERT_MSG(iPthreadError == 0, "pthread_mutex_unlock returned %d\n", iPthreadError);
     }
-    #endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 
+    #endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX
 }
 #endif // USE_GLOBAL_LOCK_FOR_SUSPENSION
 }
@@ -439,18 +438,18 @@ Function:
   AcquireSuspensionLocks
 
 AcquireSuspensionLocks is used to acquire the suspension locks
-of a suspender (or resumer) and target thread. The thread will 
+of a suspender (or resumer) and target thread. The thread will
 perform a blocking call to acquire its own suspension lock
-and will then try to acquire the target thread's lock without blocking. 
-If it fails to acquire the target's lock, it releases its own lock 
-and the thread will try to acquire both locks again. The key 
+and will then try to acquire the target thread's lock without blocking.
+If it fails to acquire the target's lock, it releases its own lock
+and the thread will try to acquire both locks again. The key
 is that both locks must be acquired together.
 
 Originally, only blocking calls were used to acquire the suspender
 and the target lock. However, this was problematic since a thread
 could acquire its own lock and then block on acquiring the target
 lock. In the meantime, the target could have already acquired its
-own lock and be attempting to suspend the suspender thread. This 
+own lock and be attempting to suspend the suspender thread. This
 clearly causes deadlock. A second approach used locking hierarchies,
 where locks were acquired use thread id ordering. This was better but
 suffered from the scenario where thread A acquires thread B's
@@ -459,13 +458,13 @@ suspension mutex and its own. Thus, thread A is suspended while
 holding thread B's mutex. This is problematic if thread C now wants
 to suspend thread B. The issue here is that a thread can be
 suspended while holding someone else's mutex but not holding its own.
-In the end, the correct approach is to always acquire your suspension 
-mutex first. This prevents you from being suspended while holding the 
-target's mutex. Then, attempt to acquire the target's mutex. If the mutex 
-cannot be acquired, release your own and try again. This all or nothing 
+In the end, the correct approach is to always acquire your suspension
+mutex first. This prevents you from being suspended while holding the
+target's mutex. Then, attempt to acquire the target's mutex. If the mutex
+cannot be acquired, release your own and try again. This all or nothing
 approach is the safest and avoids nasty race conditions.
 
-If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, the calling thread 
+If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, the calling thread
 will acquire the global lock when possible.
 --*/
 VOID
@@ -486,36 +485,36 @@ CThreadSuspensionInfo::AcquireSuspensionLocks(
         if (!TryAcquireSuspensionLock(pthrTarget))
         {
             // pthread_mutex_trylock returned EBUSY so release the first lock and try again.
-            ReleaseSuspensionLock(pthrSuspender);           
+            ReleaseSuspensionLock(pthrSuspender);
             fReacquire = TRUE;
             sched_yield();
         }
     } while (fReacquire);
 #endif // USE_GLOBAL_LOCK_FOR_SUSPENSION
 
-    // Whenever the native implementation for the wait subsystem's thread 
-    // blocking requires a lock as protection (as pthread conditions do with 
-    // the associated mutex), we need to grab that lock to prevent the target 
+    // Whenever the native implementation for the wait subsystem's thread
+    // blocking requires a lock as protection (as pthread conditions do with
+    // the associated mutex), we need to grab that lock to prevent the target
     // thread from being suspended while holding the lock.
-    // Failing to do so can lead to a multiple threads deadlocking such as the 
+    // Failing to do so can lead to a multiple threads deadlocking such as the
     // one described in VSW 363793.
-    // In general, in similar scenarios, we need to grab the protecting lock 
-    // every time suspension safety/unsafety is unbalanced on the two sides 
-    // using the same condition (or any other native blocking support which 
-    // needs an associated native lock), i.e. when either the signaling 
-    // thread(s) is(are) signaling from an unsafe area and the waiting 
+    // In general, in similar scenarios, we need to grab the protecting lock
+    // every time suspension safety/unsafety is unbalanced on the two sides
+    // using the same condition (or any other native blocking support which
+    // needs an associated native lock), i.e. when either the signaling
+    // thread(s) is(are) signaling from an unsafe area and the waiting
     // thread(s) is(are) waiting from a safe one, or vice versa (the scenario
-    // described in VSW 363793 is a good example of the first type of 
+    // described in VSW 363793 is a good example of the first type of
     // unbalanced suspension safety/unsafety).
-    // Instead, whenever signaling and waiting sides are both marked safe or 
-    // unsafe, the deadlock cannot take place since either the suspending 
-    // thread will suspend them anyway (regardless of the native lock), or it 
+    // Instead, whenever signaling and waiting sides are both marked safe or
+    // unsafe, the deadlock cannot take place since either the suspending
+    // thread will suspend them anyway (regardless of the native lock), or it
     // won't suspend any of them, since they are both marked unsafe.
-    // Such a balanced scenario applies, for instance, to critical sections 
+    // Such a balanced scenario applies, for instance, to critical sections
     // where depending on whether the target CS is internal or not, both the
-    // signaling and the waiting side will access the mutex/condition from 
+    // signaling and the waiting side will access the mutex/condition from
     // respectively an unsafe or safe region.
-    
+
     pthrTarget->AcquireNativeWaitLock();
 }
 
@@ -535,7 +534,7 @@ CThreadSuspensionInfo::ReleaseSuspensionLocks(
     CPalThread *pthrTarget
     )
 {
-    // See comment in AcquireSuspensionLocks    
+    // See comment in AcquireSuspensionLocks
     pthrTarget->ReleaseNativeWaitLock();
 
 #ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION
@@ -607,7 +606,7 @@ Function:
   WaitOnSuspendSemaphore
 
 WaitOnSuspendSemaphore is a utility function for a thread
-to wait on its POSIX or SysV suspension semaphore. 
+to wait on its POSIX or SysV suspension semaphore.
 --*/
 void
 CThreadSuspensionInfo::WaitOnSuspendSemaphore()
@@ -794,9 +793,9 @@ CThreadSuspensionInfo::InitializeSuspensionLock()
 Function:
   InitializePreCreate
 
-InitializePreCreate initializes the semaphores and signal masks used 
-for thread suspension. At the end, it sets the calling thread's 
-signal mask to the default signal mask. 
+InitializePreCreate initializes the semaphores and signal masks used
+for thread suspension. At the end, it sets the calling thread's
+signal mask to the default signal mask.
 --*/
 PAL_ERROR
 CThreadSuspensionInfo::InitializePreCreate()
@@ -814,7 +813,7 @@ CThreadSuspensionInfo::InitializePreCreate()
 #endif  // SEM_INIT_MODIFIES_ERRNO
 
     // initialize suspension semaphore
-    iError = sem_init(&m_semSusp, 0, 0);  
+    iError = sem_init(&m_semSusp, 0, 0);
 
 #if SEM_INIT_MODIFIES_ERRNO
     if (iError == 0)
@@ -863,7 +862,7 @@ CThreadSuspensionInfo::InitializePreCreate()
         ASSERT("semget for suspension sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno));
         goto InitializePreCreateExit;
     }
-    
+
     m_nSemrespid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666);
     if (m_nSemrespid == -1)
     {
@@ -892,7 +891,7 @@ CThreadSuspensionInfo::InitializePreCreate()
         ASSERT("semctl for resumption sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno));
         goto InitializePreCreateExit;
     }
-    
+
     // initialize suspend semaphore
     m_sbSemwait.sem_num = 0;
     m_sbSemwait.sem_op = -1;
@@ -901,7 +900,7 @@ CThreadSuspensionInfo::InitializePreCreate()
     // initialize resume semaphore
     m_sbSempost.sem_num = 0;
     m_sbSempost.sem_op = 1;
-    m_sbSempost.sem_flg = 0;    
+    m_sbSempost.sem_flg = 0;
 #elif USE_PTHREAD_CONDVARS
     iError = pthread_cond_init(&m_condSusp, NULL);
     if (iError != 0)
@@ -936,7 +935,7 @@ CThreadSuspensionInfo::InitializePreCreate()
 
     // Initialization was successful.
     palError = NO_ERROR;
-    
+
 InitializePreCreateExit:
 
     if (NO_ERROR == palError && 0 != iError)
@@ -1008,11 +1007,11 @@ CThreadSuspensionInfo::~CThreadSuspensionInfo()
 /*++
 Function:
   DestroySemaphoreIds
-  
+
 DestroySemaphoreIds is called from the CThreadSuspensionInfo destructor and
 from PROCCleanupThreadSemIds. If a thread exits before shutdown or is suspended
-during shutdown, its destructor will be invoked and the semaphore ids destroyed. 
-In assert or exceptions situations that are suspension unsafe, 
+during shutdown, its destructor will be invoked and the semaphore ids destroyed.
+In assert or exceptions situations that are suspension unsafe,
 PROCCleanupThreadSemIds is called, which uses DestroySemaphoreIds.
 --*/
 void