Build with -DELPP_EXPERIMENTAL_ASYNC causes segment fault as ELPP macro return nullptr
sfzhang opened this issue · comments
When build easylogging++ with -DELPP_EXPERIMENTAL_ASYNC
to enable async logging, Storage
constructor will call m_asyncDispatchWorker->start()
which creates a worker thread and join()
it. Now the Storage
constructor will not return until the worker thread finished and the global variable (el::base::type::StoragePointer elStorage(val)
) defined by INITIALIZE_EASYLOGGINGPP
macro is an unfinished-constructed std::shared_ptr
. And the worker thread will call AsyncDispatchWorker::emptyQueue()
which access ELPP
macro causes segment fault as the global variable (el::base::type::StoragePointer elStorage(val)
) is nullptr
!