Only register signals and create alt exception stack in coreclr. (#19309)
authorMike McLaughlin <mikem@microsoft.com>
Mon, 6 Aug 2018 19:16:49 +0000 (12:16 -0700)
committerGitHub <noreply@github.com>
Mon, 6 Aug 2018 19:16:49 +0000 (12:16 -0700)
commit5306f704e8b4bb30315313033880c36adca6e7f0
tree1b4d888150a3342129a402e9aaaf151e6c85a87f
parent3b9b7b6edf77819f6b9670b0857d8757e95e9fb0
Only register signals and create alt exception stack in coreclr. (#19309)

There was a couple of places where the DAC (IsValidObject, GetAppDomainForObject)
assumed that a NULL target/debuggee address would throw an exception that would
be caught by try/catch. Any other invalid address is handled with a software
exception throwed by the read memory functions. In general it is a better overall
design not to have any of the DBI/DAC, etc. code depend on hardware exceptions
being caught. On Linux the C++ runtime sometimes can't handle it. There is a
slight risk that there are other places in the DAC that make the NULL address
assumption but testing so far has found any.

Added PAL_SetInitializeDLLFlags as a fallback to allow the PAL_InitializeDLL flags
to be set for a PAL instance for the DAC where we could still register h/w signals
but not the altstack switching to reduce this risk. The flags can't be build time
conditional because we only build one coreclrpal.a library that all the modules
used. Having a PAL_InitializeFlags function doesn't really help either because of
the PAL_RegisterModule call to PAL_IntializeDLL and the LoadLibrary dance/protocol
that uses it to call the loading module's DLLMain.

Add PAL_SetInitializeFlags; remove flags from PAL_INITIALIZE and PAL_INITIALIZE_DLL
default. Add PAL_InitializeFlags() to allowing the default to be overriden.
dac.cmake
src/ToolBox/SOS/Strike/CMakeLists.txt
src/debug/daccess/dacdbiimpl.cpp
src/pal/inc/pal.h
src/pal/src/exception/signal.cpp
src/pal/src/init/pal.cpp
src/pal/src/thread/process.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp