예제 #1
0
void LLVM_ATTRIBUTE_NORETURN CrashHandler::crashByUnhandledException()
{
    std::string stack = getStacktrace();
    std::string exc = "";

    try
    {
        //throw;
    }
    catch(const std::exception &e)
    {
        exc.append(__FUNCTION__);
        exc.append(" caught unhandled exception. what(): ");
        exc.append(e.what());
    }
    catch(...)
    {
        exc.append(__FUNCTION__);
        exc.append(" caught unhandled exception. (unknown) ");
    }

    pLogFatal("<Unhandled exception! %s>\n"
              STACK_FORMAT, exc.c_str(),
              stack.c_str(), g_messageToUser);
    msgBox(
        //% "Unhandled exception!"
        qtTrId("CRASH_UNHEXC_TITLE"),
        //% "Engine has crashed because accepted unhandled exception!"
        qtTrId("CRASH_UNHEXC_MSG"));
    abortEngine(-1);
}
예제 #2
0
void LLVM_ATTRIBUTE_NORETURN CrashHandler::crashByFlood()
{
    std::string stack = getStacktrace();
    pLogFatal("<Out of memory!>\n"
              STACK_FORMAT,
              stack.c_str(), g_messageToUser);
    msgBox(
        //% "Out of memory!"
        qtTrId("CRASH_OUT_OF_MEM_TITLE"),
        //% "Engine has crashed because out of memory! Try to close other applications and restart game."
        qtTrId("CRASH_OUT_OF_MEM_MSG"));
    abortEngine(-2);
}
예제 #3
0
void CrashHandler::crashBySIGSERV(int /*signalid*/)
{
    QString crashMsg = QApplication::tr("We're sorry, but PGE Editor has crashed. \nReason: Signal Segmentation Violation [SIGSERV]\n\n");

    if(DevConsole::isConsoleShown())
        DevConsole::closeIfPossible();

    crashMsg += QString("\n\n") + getStacktrace();

    CrashHandler* crsh = new CrashHandler(crashMsg);
    crsh->exec();

    exit(EXIT_FAILURE);
}
예제 #4
0
void CrashHandler::crashByFlood()
{
    QString crashMsg = QApplication::tr("We're sorry, but PGE Editor has crashed. \nReason: Out of memory!\n\n"
                                        "To prevent this, try closing other uneccessary programs to free up more memory.");

    if(DevConsole::isConsoleShown())
        DevConsole::closeIfPossible();

    crashMsg += QString("\n\n") + getStacktrace();

    CrashHandler* crsh = new CrashHandler(crashMsg);
    crsh->exec();

    exit(EXIT_FAILURE);
}
예제 #5
0
void CrashHandler::crashByUnhandledException()
{
    std::exception_ptr unhandledException = std::current_exception();
    try{
        std::rethrow_exception(unhandledException);
    }
    catch(const std::exception& e)
    {
        QString crashMsg = QApplication::tr("We're sorry, but PGE Editor has crashed. \nReason: %1\n\nPlease inform our forum staff so we can try to fix this problem, Thank you\n\nForum link: engine.wohlnet.ru/forum").arg(e.what());

        if(DevConsole::isConsoleShown())
            DevConsole::closeIfPossible();

        crashMsg += QString("\n\n") + getStacktrace();

        CrashHandler* crsh = new CrashHandler(crashMsg);
        crsh->exec();
    }

    exit(EXIT_FAILURE);
}
void CrashHandler::doCrashScreenAndCleanup(QString crashMsg)
{
    //Force debug log enabling
    LogWriter::logLevel = PGE_LogLevel::Debug;
    //Append extra explanation to user how to report the crash
    crashMsg += g_messageToUser;
    //Write crash message into the log file first
    crashMsg += QString("\n\n") + getStacktrace();
    //Also save crash report into log file
    LogFatalNC(crashMsg);
    //Then, emergency save all opened files into reserve folder
    attemptCrashsave();

    //Close console box if possible
    if(DevConsole::isConsoleShown())
        DevConsole::closeIfPossible();

    MainWinConnect::pMainWin->hide();
    //And now, spawn dialog box with stack trance
    CrashHandler *crsh = new CrashHandler(crashMsg);
    crsh->exec();
    delete crsh;
}
예제 #7
0
static void handle_signal(int signal, siginfo_t *siginfo, void * /*context*/)
{
#ifdef _WIN32  //Unsupported signals by Windows
    (void)siginfo;
#endif

    // Find out which signal we're handling
    switch(signal)
    {
#ifndef _WIN32  //Unsupported signals by Windows

    case SIGHUP:
        pLogWarning("Terminal was closed");
        abortEngine(signal);

    case SIGQUIT:
        pLogWarning("<Quit command>");
        abortEngine(signal);

    case SIGKILL:
        pLogFatal("<killed>");
        abortEngine(signal);

    case SIGALRM:
    {
        pLogFatal("<alarm() time out!>");
        msgBox(
            //% "Time out!"
            qtTrId("CRASH_TIMEOUT_TITLE"),
            //% "Engine has abourted because alarm() time out!"
            qtTrId("CRASH_TIMEOUT_MSG"));
        abortEngine(signal);
    }

    case SIGBUS:
    {
        std::string stack = getStacktrace();

        if(siginfo)
        {
            switch(siginfo->si_code)
            {
            case BUS_ADRALN:
                pLogFatal("<Physical memory address error: wrong address alignment>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case BUS_ADRERR:
                pLogFatal("<Physical memory address error: physical address is not exists>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case BUS_OBJERR:
                pLogFatal("<Physical memory address error: object specific hardware error>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            default:
                pLogFatal("<Physical memory address error>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
            }
        }
        else
        {
            pLogFatal("<Physical memory address error>\n"
                      STACK_FORMAT,
                      stack.c_str(), g_messageToUser);
        }

        msgBox(
            //% "Physical memory address error!"
            qtTrId("CRASH_BUS_TITLE"),
            //% "Engine has crashed because a physical memory address error"
            qtTrId("CRASH_BUS_MSG"));
        abortEngine(signal);
    }

    case SIGURG:
    case SIGUSR1:
    case SIGUSR2:
        break;

    case SIGILL:
    {
        std::string stack = getStacktrace();
        pLogFatal("<Wrong CPU Instruction>\n"
                  STACK_FORMAT,
                  stack.c_str(), g_messageToUser);
        msgBox(
            //% "Wrong CPU Instruction!"
            qtTrId("CRASH_ILL_TITLE"),
            //% "Engine has crashed because a wrong CPU instruction"
            qtTrId("CRASH_ILL_MSG"));
        abortEngine(signal);
    }

#endif

    case SIGFPE:
    {
        std::string stack = getStacktrace();
#ifndef _WIN32  //Unsupported signals by Windows

        if(siginfo)
        {
            switch(siginfo->si_code)
            {
            case FPE_INTDIV:
                pLogFatal("<wrong arithmetical operation: division of integer number by zero>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case FPE_FLTDIV:
                pLogFatal("<wrong arithmetical operation: division of floating point number by zero>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case FPE_INTOVF:
                pLogFatal("<wrong arithmetical operation: integer number max bits size overflot>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case FPE_FLTOVF:
                pLogFatal("<wrong arithmetical operation: floating point number max bits size overflot>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            default:
                pLogFatal("<wrong arithmetical operation>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
            }
        }
        else
#endif
        {
            pLogFatal("<wrong arithmetical operation>\n"
                      STACK_FORMAT,
                      stack.c_str(), g_messageToUser);
        }

        msgBox(
            //% "Wrong arithmetical operation"
            qtTrId("CRASH_FPE_TITLE"),
            //% "Engine has crashed because of a wrong arithmetical operation!"
            qtTrId("CRASH_FPE_MSG"));
        abortEngine(signal);
    }

    case SIGABRT:
    {
        std::string stack = getStacktrace();
        pLogFatal("<Aborted!>\n"
                  STACK_FORMAT,
                  stack.c_str(), g_messageToUser);
        msgBox(
            //% "Aborted"
            qtTrId("CRASH_ABORT_TITLE"),
            //% "Engine has been aborted because critical error was occouped."
            qtTrId("CRASH_ABORT_TITLE."));
        abortEngine(signal);
    }

    case SIGSEGV:
    {
        D_pLogDebug("\n===========================================================\n"
                    "Attempt to take a backtrace..."
                    "(if log ends before \"DONE\" will be shown, seems also trouble in the backtracing function too...)");
        std::string stack = getStacktrace();
#ifndef _WIN32  //Unsupported signals by Windows

        if(siginfo)
        {
            switch(siginfo->si_code)
            {
            case SEGV_MAPERR:
                pLogFatal("<Segmentation fault crash!: Address is not pointing to object!!!>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            case SEGV_ACCERR:
                pLogFatal("<Segmentation fault crash!: Wrong access rights for address!!!>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;

            default:
                pLogFatal("<Segmentation fault crash!>\n"
                          STACK_FORMAT,
                          stack.c_str(), g_messageToUser);
                break;
            }
        }
        else
#endif
        {
            pLogFatal("<Segmentation fault crash!>\n"
                      STACK_FORMAT,
                      stack.c_str(), g_messageToUser);
        }

        msgBox(
            //% "Segmentation fault"
            qtTrId("CRASH_SIGSEGV_TITLE"),
            /*% "Engine has crashed because of a Segmentation fault.\n"
                "Run debugging with a built in debug mode application\n"
                "and retry your recent actions to get more detailed information." */
            qtTrId("CRASH_SIGSEGV_MSG."));
        abortEngine(signal);
    }

    case SIGINT:
    {
        pLogFatal("<Interrupted!>");
        msgBox(
            //% "Interrupt"
            qtTrId("CRASH_INT_TITLE"),
            //% "Engine has been interrupted"
            qtTrId("CRASH_INT_MSG"));
        abortEngine(signal);
    }

    default:
        return;
    }
}