Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/coreclr/dlls/mscoree/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ int coreclr_initialize(
// This will take ownership of propertyKeysWTemp and propertyValuesWTemp
Configuration::InitializeConfigurationKnobs(propertyCount, propertyKeysW, propertyValuesW);

#ifdef TARGET_UNIX
if (Configuration::GetKnobBooleanValue(W("System.Runtime.CrashReportBeforeSignalChaining"), CLRConfig::INTERNAL_CrashReportBeforeSignalChaining))
{
PAL_EnableCrashReportBeforeSignalChaining();
}
#endif

STARTUP_FLAGS startupFlags;
InitializeStartupFlags(&startupFlags);

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_DbgEnableMiniDump, W("DbgEnableMiniDump"), 0,
RETAIL_CONFIG_STRING_INFO(INTERNAL_DbgMiniDumpName, W("DbgMiniDumpName"), "Crash dump name")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_DbgMiniDumpType, W("DbgMiniDumpType"), 0, "Crash dump type: 1 normal, 2 withheap, 3 triage, 4 full")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_CreateDumpDiagnostics, W("CreateDumpDiagnostics"), 0, "Enable crash dump generation diagnostic logging")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_CrashReportBeforeSignalChaining, W("CrashReportBeforeSignalChaining"), 0, "Enable crash report generation before chaining to previous signal handler")

///
/// R2R
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ PALAPI
PAL_SetCreateDumpCallback(
IN PCREATEDUMP_CALLBACK callback);

PALIMPORT
VOID
PALAPI
PAL_EnableCrashReportBeforeSignalChaining(
void);

PALIMPORT
BOOL
PALAPI
Expand Down
37 changes: 33 additions & 4 deletions src/coreclr/pal/src/exception/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ bool g_registered_signal_handlers = false;
#if !HAVE_MACH_EXCEPTIONS
bool g_enable_alternate_stack_check = false;
#endif // !HAVE_MACH_EXCEPTIONS
// When true, generate crash dump before invoking previously registered signal handler
static bool g_crash_report_before_signal_chaining = false;

static bool g_registered_sigterm_handler = false;
static bool g_registered_activation_handler = false;
Expand Down Expand Up @@ -133,6 +135,22 @@ const int StackOverflowFlag = 0x40000000;

/* public function definitions ************************************************/

/*++
Function:
PAL_EnableCrashReportBeforeSignalChaining

Abstract:
Enables generating a crash report before the signal is chained to previous handlers.
--*/
PALIMPORT
VOID
PALAPI
PAL_EnableCrashReportBeforeSignalChaining(
void)
{
g_crash_report_before_signal_chaining = true;
}

/*++
Function :
SEHInitializeSignals
Expand Down Expand Up @@ -447,7 +465,16 @@ static void invoke_previous_action(struct sigaction* action, int code, siginfo_t
PROCAbort(code, siginfo, context);
}
}
else if (IsSaSigInfo(action))

_ASSERTE(!IsSigDfl(action) && !IsSigIgn(action));

if (g_crash_report_before_signal_chaining)
{
PROCNotifyProcessShutdown(IsRunningOnAlternateStack(context));
PROCCreateCrashDumpIfEnabled(code, siginfo, context, true);
}

if (IsSaSigInfo(action))
{
// Directly call the previous handler.
_ASSERTE(action->sa_sigaction != NULL);
Expand All @@ -460,9 +487,11 @@ static void invoke_previous_action(struct sigaction* action, int code, siginfo_t
action->sa_handler(code);
}

PROCNotifyProcessShutdown(IsRunningOnAlternateStack(context));

PROCCreateCrashDumpIfEnabled(code, siginfo, context, true);
if (!g_crash_report_before_signal_chaining)
{
PROCNotifyProcessShutdown(IsRunningOnAlternateStack(context));
PROCCreateCrashDumpIfEnabled(code, siginfo, context, true);
}
}

/*++
Expand Down
1 change: 1 addition & 0 deletions src/tasks/AndroidAppBuilder/Templates/monodroid-coreclr.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ mono_droid_runtime_init (const char* executable)
#ifdef DIAGNOSTIC_PORTS
setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true);
#endif
setenv ("DOTNET_CrashReportBeforeSignalChaining", "1", true);

if (bundle_executable_path(executable, g_bundle_path, &g_executable_path) < 0)
{
Expand Down
Loading