abumq / easyloggingpp

C++ logging library. It is powerful, supports asynchronous low latency, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.78k stars 925 forks source link

crash in easylogging initialization when using a shared library setup #640

Open a1non2ymous opened 6 years ago

a1non2ymous commented 6 years ago

I have a crash everytime I try to build and use easylogging in my application: (gdb) bt #0 0x080e11f8 in gnu_cxx::new_allocator<el::Configuration>::construct<el::Configuration, el::Configuration* const&> (this=0x811fdc8, p=0x1) #1 0x080e0f57 in std::allocator_traits<std::allocator<el::Configuration> >::construct<el::Configuration, el::Configuration const&> (a=..., p=0x1) #2 0x080e0d68 in std::vector<el::Configuration, std::allocator<el::Configuration*> >::push_back (this=0x811fdc8, x=@0xffffc944: 0x811f000) #3 0x080e0ac8 in el::base::utils::RegistryWithPred<el::Configuration, el::Configuration::Predicate>::registerNew (this=0x811fdac, ptr=0x811f000) at Linux_i686/gcc_5/easyloggingpp_9.96.4/include/easylogging++.h:1501 #4 0xf7957cea in el::Configurations::unsafeSet(el::Level, el::ConfigurationType, std::string const&) () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #5 0xf79555e6 in el::Configurations::set(el::Level, el::ConfigurationType, std::string const&) () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #6 0xf7957ddd in el::Configurations::setGlobally(el::ConfigurationType, std::string const&, bool) () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #7 0xf7955707 in el::Configurations::setToDefault() () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #8 0xf795f835 in el::base::RegisteredLoggers::RegisteredLoggers(std::shared_ptr const&) () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #9 0xf796149c in el::base::Storage::Storage(std::shared_ptr const&) () from Linux_i686/gcc_5/easyloggingpp_9.96.4/lib/libeasyloggingpp.so #10 0x080dacbb in static_initialization_and_destruction_0 (initialize_p=1, priority=65535) at myclass.cpp:19 #11 0x080dafb8 in _GLOBAL__sub_IZN2el4base9elStorageE () at myclass.cpp:552 #12 0x080e186b in libc_csu_init () #13 0xf756ce13 in libc_start_main (main=0x80da4cb <main(int, char**)>, argc=1, argv=0xffffcc34, init=0x80e1820 <libc_csu_init>, fini=0x80e1880 <__libc_csu_fini>, rtld_fini=0xf7fe59b0 <_dl_fini>, stack_end=0xffffcc2c) at ../csu/libc-start.c:266

Easylogging++ v9.96.4 gcc version --> 5.x i tried with both static and shared versions. flags: -D_GLIBCXX_USE_CXX11_ABI=0 -D_ELPP_THREAD_SAFE=1 -DELPP_DISABLE_DEFAULT_CRASH_HANDLING=1

a1non2ymous commented 6 years ago

Any suggestions people?

a1non2ymous commented 6 years ago

so, further debugging: crash on exiting and unloading the libraries using easylogging:

==12887==ERROR: AddressSanitizer: heap-use-after-free on address 0xf4913874 at pc 0x5677888d bp 0xffc90a98 sp 0xffc90a88 WRITE of size 4 at 0xf4913874 thread T0

0 0x5677888c in std::shared_ptr::~shared_ptr() (test2.so+0x13588c)

#1 0xf675e792 in __cxa_finalize (/lib/i386-linux-gnu/libc.so.6+0x30792)

0xf4913874 is located 4 bytes inside of 16-byte region [0xf4913870,0xf4913880) freed by thread T0 here:

0 0xf79bee84 in operator delete(void*) (/usr/lib32/libasan.so.4+0xe7e84)

#1 0x56777f59 in std::_Sp_counted_ptr<el::base::Storage*, (__gnu_cxx::_Lock_policy)2>::_M_destroy() (test1+0x134f59)

previously allocated by thread T0 here:

0 0xf79be084 in operator new(unsigned int) (/usr/lib32/libasan.so.4+0xe7084)

#1 0x5665c6a3 in _GLOBAL__sub_I_test1.cpp (test1+0x196a3)
#2 0x567d9e2a in __libc_csu_init (test1+0x196e2a)

Any suggestions welcome.

StanOnix commented 5 years ago

Hello,

Any suggestions on this ? I encounter the same issue