easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

Segmentation fault with ELPP_THREAD_SAFE

Open DmitryDemidov80 opened this issue 5 years ago • 4 comments

Hi! I'm using version 9.96.7. I built static lib with ELPP_THREAD_SAFE. I've got segmentation fault: bt gdb output: #0 0x0004dfdc in el::base::TypedConfigurations::logFormat(el::Level) () #1 0x00052d58 in el::base::DefaultLogBuilder::build[abi:cxx11](el::LogMessage const*, bool) const () #2 0x00056718 in el::base::DefaultLogDispatchCallback::handle(el::LogDispatchData const*) () #3 0x00054f94 in el::base::LogDispatcher::dispatch() () #4 0x00059e18 in el::base::Writer::triggerDispatch() () #5 0x00059a80 in el::base::Writer::processDispatch() () #6 0x000363ac in el::base::Writer::~Writer() () #7 ----- call from my method from thread --- I'm using easylogging in my library "MyLib" and in my project wich using "MyLib" library.

DmitryDemidov80 avatar Aug 14 '19 09:08 DmitryDemidov80

Can confirm that this happens on my machine as well.

MacOS 10.15 Catalina.

Weyzu avatar Dec 23 '19 18:12 Weyzu

Did you compile all files that use EasyLogging++ with -DELPP_THREAD_SAFE or just the static library? If not, no locks are aqcuired and it'll crash at some point. Best way to use ELPP is by not building a static lib, but adding the .cc and .h files to your project and define all required ELPP_* macros you need for all compilation units. Otherwise, your static library may use different code from the ELPP header than your application.

kblaschke avatar May 12 '20 07:05 kblaschke

-DELPP_THREAD_SAFE only for static library.

DmitryDemidov80 avatar May 12 '20 07:05 DmitryDemidov80

Then you may try defining this macro in every compilation unit that (directly or indirectly) includes any ELPP header (or for simplicity just add it globally to your project's build configuration), as the switch also affects a lot of stuff in the header file as well. This would possibly cause incompatible implementations being used throughout your project, e.g. some locks not being in place where they should be.

kblaschke avatar Sep 06 '20 10:09 kblaschke