easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

On crash, log line number and file in source code

Open khlitoshi opened this issue 8 years ago • 9 comments

Hi,

Sorry if this is not the right place to ask for this, I am in urgent need for an answer.

I need to get line number and filename in source code when unhandled exception occurs.

but I am getting this instead, which is the line number inside the logging library.

2016-08-09 11:43:29,968 WARN easylogging++.h 5627 Aborting application. Reason: Fatal log at [ c:\vsprojects\loglibtest\loglibtest\easylogging++.h : 5627 ]

Can anyone help me solve the issue. below is sample code I'm using


#define ELPP_THREAD_SAFE

#define ELPP_CUSTOM_COUT std::cerr
#include "easylogging++.h"
#define _ELPP_STACKTRACE_ON_CRASH


INITIALIZE_EASYLOGGINGPP

void myCrashHandler(int sig) 
{
    LOG(ERROR) << "Application crashed!";

    el::Helpers::logCrashReason(sig, true);
    el::Loggers::flushAll();
    el::Helpers::crashAbort(sig); // FOLLOWING LINE IS ABSOLUTELY NEEDED AT THE END IN ORDER TO ABORT APPLICATION
    el::Loggers::flushAll();
}

void main()
{
    el::Helpers::setCrashHandler(myCrashHandler);
    el::Loggers::addFlag(el::LoggingFlag::LogDetailedCrashReason);

    int* i;
    *i = 0; // Crash!

    return 0;
}

khlitoshi avatar Aug 09 '16 02:08 khlitoshi

@mkhan3189 +1

JasCodes avatar Aug 10 '16 20:08 JasCodes

Same problem with me:

CRASH HANDLED; Application has crashed due to [SIGSEGV] signal 2016-09-30 10:16:18,292 WARN [default] Aborting application. Reason: Fatal log at [/myuser/lib/easylogging++.h:5627]

maiconkist avatar Sep 30 '16 09:09 maiconkist

+1

andreivirtosu avatar Nov 06 '16 13:11 andreivirtosu

I had the same problem: 2016-11-12 23:45:23.507321 F easylogging++.h:5627 CRASH HANDLED; Application has crashed due to [SIGSEGV] signal

korst1k avatar Nov 12 '16 20:11 korst1k

+1

Chrisliu0915 avatar Jan 27 '17 23:01 Chrisliu0915

F [2017-02-08 19:06:10] [easylogging++.h:5627] CRASH HANDLED; Application has crashed due to [SIGSEGV] signal W [2017-02-08 19:06:10] [easylogging++.h:5627] Aborting application. Reason: Fatal log at [./inc/easylogging++.h:5627]

xserver avatar Feb 08 '17 11:02 xserver

I just rebooted my machine and the error is gone :)

mikeleatila avatar Apr 03 '18 16:04 mikeleatila

Same behavior here:

2021-06-01 14:45:34,934666 - ERROR - Application crashed!
2021-06-01 14:45:34,934697 - FATAL - CRASH HANDLED; Application has crashed due to [SIGSEGV] signal
    Invalid access to memory
    Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory.
    ======= Backtrace: =========

2021-06-01 14:45:34,934707 - WARNING - Aborting application. Reason: Fatal log at [/path/libs/easyloggingpp/src/easylogging++.cc:2884]

But in my case the Backtrace is empty. I have in my cmake lists:

add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
add_definitions(-DELPP_THREAD_SAFE)
add_definitions(-DELPP_FEATURE_CRASH_LOG)

target_compile_options(${PROJECT_NAME} PRIVATE -O3)

my gcc / OS are:

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Any ideas? Thanks!

doleron avatar Jun 01 '21 18:06 doleron