Skip to content

CrashHandler breaks custom crash handlers #121494

Description

@0x0ACB

Tested versions

4.7

System information

Windows 11, Ubuntu 26.04

Issue description

This is mainly an issue with libgodot but the CrashHandlers for Windows and Linux will not restore previous signal handlers when disabled. Since they can not be disabled before initializing godot and will always set their own signal handlers it is currently impossible to setup custom crash handling beforehand with something like breakpad.

void CrashHandler::disable() {
if (disabled) {
return;
}
#if defined(CRASH_HANDLER_EXCEPTION)
signal(SIGSEGV, nullptr);
signal(SIGFPE, nullptr);
signal(SIGILL, nullptr);
#endif
disabled = true;
}
void CrashHandler::initialize() {
#if defined(CRASH_HANDLER_EXCEPTION)
signal(SIGSEGV, CrashHandlerException);
signal(SIGFPE, CrashHandlerException);
signal(SIGILL, CrashHandlerException);
#endif
}

void CrashHandler::disable() {
if (disabled) {
return;
}
#ifdef CRASH_HANDLER_ENABLED
signal(SIGSEGV, SIG_DFL);
signal(SIGFPE, SIG_DFL);
signal(SIGILL, SIG_DFL);
#endif
disabled = true;
}
void CrashHandler::initialize() {
#ifdef CRASH_HANDLER_ENABLED
signal(SIGSEGV, handle_crash);
signal(SIGFPE, handle_crash);
signal(SIGILL, handle_crash);
#endif
}

Steps to reproduce

init_breakpad();
const auto instance = static_cast<GodotInstance*>(libgodot_create_godot_instance(argc, argv, gdextension_init));
OS::get_singleton()->disable_crash_handler();
CRASH_NOW();

Minimal reproduction project (MRP)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions