-
-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when i use #define ELPP_THREAD_SAFE #310
Comments
Warning has nothing to do with crash We've seen cases like this when u have macro in one file not in other. Why don't people define it as compiler option? I don't understand |
still it is crashing when I am setting as compiler option in Project Properties-->C/C++ --> Preprocessor - ELPP_THREAD_SAFE |
does it crash when you use macro ( |
can you run this sample? What platform are you using? (compiler and OS specifically) |
i am using windows and when i used LOG(WARNING) it doesnt crash. Now i tried this very liitle code - and its crashing - #define ELPP_THREAD_SAFE #include "easylogging++.h" INITIALIZE_EASYLOGGINGPP and when i comment the line #define ELPP_THREAD_SAFE, it works well. |
try |
i tried CLOG(WARN, "main") << "abc"; compile errors - |
what compiler is it? have you tried the sample i asked you to run? |
also can you try to If this works then you have problem with registering the logger. try using valgrind to find whether it's getting enough memory to register new logger |
this code also crashing - #include "easylogging++.h" INITIALIZE_EASYLOGGINGPP |
hmm what about pthread.cc sample? what compiler is this? what version of c++? what windows? if you don't provide enough details i'm afraid i won't be able to help you |
windows 7 service pack 1 |
CLOG(WARNING, "main") << "abc"; worked well with #define ELPP_THREAD_SAFE. |
@mkhan3189 you ask "Why don't people define it as compiler option? I don't understand" It's because the documentation does not even make it clear that these flags need to be #defined before including easylogging++.h and the documentation calls them "Configuration Macros" which is the wrong word for a pre-processor configuration constant, imho. btw. I found this thread while trying to work out how to use these "macros" |
I am re-opening this because I am also experiencing a crash when logging very It seems to be some sort of race condition. What makes me say that is that when Platform: ubuntu 14.04 x86-64 This is not compiler-specific: the same crash also occurs Here are the flags all my code is compiled with:
Here's how I initialize the logging library:
Here's a gdb stack dump of the crash #0 0x000000000060a060 in el::base::DefaultLogDispatchCallback::dispatch(std::string&&) (this=0xa5af00, Here's the offending line (line 4205) : (gdb) l Finally, to confirm the misbehavior, I ran it with valgrind. ==2935== Invalid read of size 8 The offending line (3343) where the bad read occur:
|
Crash has nothing to do with thread as assert failure suggests, ypu remove file configuration somewhere but didnt unset to file config If you look at this sample and uncomment lines in the end and run and if it crashes it's related to thread if not it's ur config that u change in one of the 72 threads https://github.com/easylogging/easyloggingpp/blob/master/samples/STL/pthread.cpp |
I never change the logging configuration after I set it in the main.
I just downloaded the sample, and as you suggested, I uncommented the lines at the end Here's the stack dump under gdb: #0 malloc_consolidate (av=av@entry=0x7ffff0000020) at malloc.c:4151 Here's valgrind: ==28925== Thread 4: |
I am also having this problem running on Ubuntu 16.04 LTS. I am using G++ to compile. I am thinking it may be a compiler problem. |
I confirm the behaviour on Ubuntu 16.04LTS using GCC 5.4.0. |
I'm also having trouble with this. Here is my complete source code: #define ELPP_THREAD_SAFE
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
int main(int argc, char **argv) {
START_EASYLOGGINGPP(argc, argv);
LOG(INFO) << "My first info log using default logger";
return 0;
} And this is what I get:
|
I am facing crash when i use this macro. My code snippet looks like this -
define ELPP_THREAD_SAFE
define ELPP_NO_DEFAULT_LOG_FILE
include "../easylogging++.h"
when i build it, i get follwing warning -
easylogging++.h(1029): warning C4100: 'ms' : unreferenced formal parameter
and i am very sure crash is due to the macro. As when i comment the line, //#define ELPP_THREAD_SAFE, crash goes off.
Is it because of the above warning ?
So please suggest what should i change/add ? Also the macro is ELPP_THREAD_SAFE & not _ELPP_THREAD_SAFE, but many times in answers i found it as _ELPP_THREAD_SAFE.
The text was updated successfully, but these errors were encountered: