Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7813233

Browse files
author
Mike McLaughlin
authored
Only register signals and create alt exception stack in coreclr (#19526)
Free the alternate signal stack if this PAL's thread allocated it. (#19539) Move Ensure/FreeSignalAlternateStack to CPalThread class. Frees the alternate stack a little sooner during thread termination. Fixed SOS plugin for core dumps.
1 parent 6b3fd2f commit 7813233

File tree

15 files changed

+324
-226
lines changed

15 files changed

+324
-226
lines changed

dac.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Contains the dac build specific definitions. Included by the leaf dac cmake files.
22

33
add_definitions(-DDACCESS_COMPILE)
4-
add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS)
54
if(WIN32)
65
add_definitions(-MT)
76
endif(WIN32)

src/ToolBox/SOS/Strike/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ if(WIN32)
105105
ntdll.lib
106106
)
107107
else(WIN32)
108-
add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS)
109108
add_definitions(-DPAL_STDCPP_COMPAT=1)
110109
add_compile_options(-Wno-null-arithmetic)
111110
add_compile_options(-Wno-format)

src/ToolBox/SOS/lldbplugin/services.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ LLDBServices::ReadVirtual(
771771
{
772772
*bytesRead = read;
773773
}
774-
return error.Success() ? S_OK : E_FAIL;
774+
return error.Success() || (read != 0) ? S_OK : E_FAIL;
775775
}
776776

777777
HRESULT
@@ -800,7 +800,7 @@ LLDBServices::WriteVirtual(
800800
{
801801
*bytesWritten = written;
802802
}
803-
return error.Success() ? S_OK : E_FAIL;
803+
return error.Success() || (written != 0) ? S_OK : E_FAIL;
804804
}
805805

806806
//----------------------------------------------------------------------------

src/debug/daccess/dacdbiimpl.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6804,24 +6804,28 @@ bool DacDbiInterfaceImpl::IsValidObject(CORDB_ADDRESS addr)
68046804
DD_ENTER_MAY_THROW;
68056805

68066806
bool isValid = false;
6807-
EX_TRY
6808-
{
6809-
PTR_Object obj(TO_TADDR(addr));
6810-
6811-
PTR_MethodTable mt = obj->GetMethodTable();
6812-
PTR_EEClass cls = mt->GetClass();
6813-
6814-
if (mt == cls->GetMethodTable())
6815-
isValid = true;
6816-
else if (!mt->IsCanonicalMethodTable())
6817-
isValid = cls->GetMethodTable()->GetClass() == cls;
6818-
}
6819-
EX_CATCH
6807+
6808+
if (addr != 0 && addr != (CORDB_ADDRESS)-1)
68206809
{
6821-
isValid = false;
6810+
EX_TRY
6811+
{
6812+
PTR_Object obj(TO_TADDR(addr));
6813+
6814+
PTR_MethodTable mt = obj->GetMethodTable();
6815+
PTR_EEClass cls = mt->GetClass();
6816+
6817+
if (mt == cls->GetMethodTable())
6818+
isValid = true;
6819+
else if (!mt->IsCanonicalMethodTable())
6820+
isValid = cls->GetMethodTable()->GetClass() == cls;
6821+
}
6822+
EX_CATCH
6823+
{
6824+
isValid = false;
6825+
}
6826+
EX_END_CATCH(SwallowAllExceptions)
68226827
}
6823-
EX_END_CATCH(SwallowAllExceptions)
6824-
6828+
68256829
return isValid;
68266830
}
68276831

@@ -6830,6 +6834,11 @@ bool DacDbiInterfaceImpl::GetAppDomainForObject(CORDB_ADDRESS addr, OUT VMPTR_Ap
68306834
{
68316835
DD_ENTER_MAY_THROW;
68326836

6837+
if (addr == 0 || addr == (CORDB_ADDRESS)-1)
6838+
{
6839+
return false;
6840+
}
6841+
68336842
PTR_Object obj(TO_TADDR(addr));
68346843
MethodTable *mt = obj->GetMethodTable();
68356844

src/pal/inc/pal.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,22 @@ typedef long time_t;
321321
#define PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER 0x08
322322
#define PAL_INITIALIZE_DEBUGGER_EXCEPTIONS 0x10
323323
#define PAL_INITIALIZE_ENSURE_STACK_SIZE 0x20
324+
#define PAL_INITIALIZE_REGISTER_SIGNALS 0x40
324325

325326
// PAL_Initialize() flags
326-
#define PAL_INITIALIZE (PAL_INITIALIZE_SYNC_THREAD | PAL_INITIALIZE_STD_HANDLES)
327+
#define PAL_INITIALIZE (PAL_INITIALIZE_SYNC_THREAD | \
328+
PAL_INITIALIZE_STD_HANDLES)
327329

328-
// PAL_InitializeDLL() flags - don't start any of the helper threads
329-
#define PAL_INITIALIZE_DLL PAL_INITIALIZE_NONE
330+
// PAL_InitializeDLL() flags - don't start any of the helper threads or register any exceptions
331+
#define PAL_INITIALIZE_DLL PAL_INITIALIZE_NONE
330332

331333
// PAL_InitializeCoreCLR() flags
332-
#define PAL_INITIALIZE_CORECLR (PAL_INITIALIZE | PAL_INITIALIZE_EXEC_ALLOCATOR | PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER | PAL_INITIALIZE_DEBUGGER_EXCEPTIONS | PAL_INITIALIZE_ENSURE_STACK_SIZE)
334+
#define PAL_INITIALIZE_CORECLR (PAL_INITIALIZE | \
335+
PAL_INITIALIZE_EXEC_ALLOCATOR | \
336+
PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER | \
337+
PAL_INITIALIZE_DEBUGGER_EXCEPTIONS | \
338+
PAL_INITIALIZE_ENSURE_STACK_SIZE | \
339+
PAL_INITIALIZE_REGISTER_SIGNALS)
333340

334341
typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
335342
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
@@ -343,10 +350,23 @@ PAL_Initialize(
343350
int argc,
344351
const char * const argv[]);
345352

353+
PALIMPORT
354+
void
355+
PALAPI
356+
PAL_InitializeWithFlags(
357+
DWORD flags);
358+
346359
PALIMPORT
347360
int
348361
PALAPI
349-
PAL_InitializeDLL(VOID);
362+
PAL_InitializeDLL(
363+
VOID);
364+
365+
PALIMPORT
366+
void
367+
PALAPI
368+
PAL_SetInitializeDLLFlags(
369+
DWORD flags);
350370

351371
PALIMPORT
352372
DWORD

src/pal/src/exception/seh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Return value :
8181
BOOL
8282
SEHInitialize (CPalThread *pthrCurrent, DWORD flags)
8383
{
84-
if (!SEHInitializeSignals(flags))
84+
if (!SEHInitializeSignals(pthrCurrent, flags))
8585
{
8686
ERROR("SEHInitializeSignals failed!\n");
8787
SEHCleanup();

0 commit comments

Comments
 (0)