easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

Build with -DELPP_EXPERIMENTAL_ASYNC causes segment fault as ELPP macro return nullptr

Open sfzhang opened this issue 2 years ago • 0 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!

sfzhang avatar Jan 16 '23 02:01 sfzhang