easyloggingpp
easyloggingpp copied to clipboard
Printf style logger crashes when in multi-threaded mode
I'm writing some code for the Mac as was going to potentially use easyloggingpp. I was experimenting with the library, but found that there is an assertion hit in the locked_guard code. It looks like the dtor is being called twice.
Assertion failed: (e == 0), function unlock, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/libcxx/libcxx-307.5/src/mutex.cpp, line 102.
These dtors are being called at the exit of the function
template <typename T>
inline void Logger::log(Level level, const T& log) {
base::threading::ScopedLock scopedLock(lock());
log_(level, 0, log);
}
I'm running Xcode 8.3.1. I have defined
-DELPP_THREAD_SAFE
-DELPP_FORCE_USE_STD_THREAD
My test code is pretty simple. The macros work fine.
//LOG(INFO) << "First log message";
//LOG(WARNING) << "This is a warning";
el::Logger *defLogger = el::Loggers::getLogger("default");
defLogger->warn("Printf style");
I don't have any configuration defined.
I'm also having the same problem. Here is my sample code to try it:
//easylogging defines //#define ELPP_DEFAULT_LOG_FILE #define ELPP_NO_DEFAULT_LOG_FILE //dont create log file by default #define ELPP_THREAD_SAFE #define ELPP_FORCE_USE_STD_THREAD #define ELPP_STL_LOGGING //define for default stl logger #include "easylogging++.h"
int main(int argc, char *argv[]) {
el::Logger* defaultLogger = el::Loggers::getLogger("default"); defaultLogger->info("testing easylogging");
}
The sample code in the comment above needs an INITIALIZE_EASYLOGGINGPP:
//easylogging defines
//#define ELPP_DEFAULT_LOG_FILE
#define ELPP_NO_DEFAULT_LOG_FILE //dont create log file by default
#define ELPP_THREAD_SAFE
#define ELPP_FORCE_USE_STD_THREAD
#define ELPP_STL_LOGGING //define for default stl logger
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
int main(int argc, char *argv[]) {
el::Logger* defaultLogger = el::Loggers::getLogger("default");
defaultLogger->info("testing easylogging");
}