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.79k stars 927 forks source link

Crash when reconfigure #546

Open n-bes opened 7 years ago

n-bes commented 7 years ago

Crash on all define configurations and on linux/win.

MCV Crash dump

#include <atomic>
#include <chrono>
#include <thread>
#include <vector>

#define ELPP_NO_DEFAULT_LOG_FILE
#define ELPP_THREAD_SAFE
#include <easylogging++.h>
INITIALIZE_EASYLOGGINGPP

int main(int argc, char const *argv[]){
    el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Filename, "logs/%datetime{%Y-%M-%d__%H-%m-%s}.log");
    el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%level %datetime: %msg");

    LOG(INFO) << "First message";

    std::atomic_bool isRun = {true};
    std::vector <std::thread> threads;
    const int threadCount = 10;
    for(int i = 0; i < threadCount; ++i){
        threads.push_back(std::thread([&](){
            while(isRun){
                LOG(INFO) << "Hello log";
            }
        }));
    }

    const auto stopTime = std::chrono::system_clock::now() + std::chrono::seconds(5);
    do{
        el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Filename, "logs/%datetime{%Y-%M-%d__%H-%m-%s}.log");
    } while (stopTime > std::chrono::system_clock::now());

    isRun = false;
    for (auto &thread: threads){
        thread.join();
    }

    return 0;
}
n-bes commented 3 years ago

AddressSanitizer:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==85921==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffffffffffe8 (pc 0x7fff202c96d0 bp 0x7ffee6bb8210 sp 0x7ffee6bb8200 T0)
==85921==The signal is caused by a READ memory access.
    #0 0x7fff202c96d0 in std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+0x10 (libc++.1.dylib:x86_64+0x136d0)
    #1 0x109052166 in std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) ostream:726
    #2 0x109051f0b in std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) ostream:869
    #3 0x109051e4d in el::base::MessageBuilder::operator<<(char const*) easylogging++.h:2926
    #4 0x10904d11d in el::base::Writer& el::base::Writer::operator<<<char [14]>(char const (&) [14]) easylogging++.h:3243
    #5 0x10904c891 in main main.cpp:15
    #6 0x7fff20375620 in start+0x0 (libdyld.dylib:x86_64+0x15620)

==85921==Register values:
rax = 0x0000000000000000  rbx = 0x00007ffee6bb82a0  rcx = 0x00007ffee6bb8240  rdx = 0x00007ffee6bb8260  
rdi = 0x00007ffee6bb8240  rsi = 0x0000615000000380  rbp = 0x00007ffee6bb8210  rsp = 0x00007ffee6bb8200  
 r8 = 0x0000615000000380   r9 = 0x2ea15b76dbea007b  r10 = 0x2ea15b76dbea007b  r11 = 0x00000000000001c0  
r12 = 0x00007ffee6bb8700  r13 = 0x00007ffee6bb8710  r14 = 0x00007ffee6bb86c0  r15 = 0x00007ffee6bb86e0  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (libc++.1.dylib:x86_64+0x136d0) in std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+0x10
==85921==ABORTING
[1]    85921 abort      ./el_bug

ThreadSanitizer:

ThreadSanitizer:DEADLYSIGNAL
==86053==ERROR: ThreadSanitizer: SEGV on unknown address 0xffffffffffffffe8 (pc 0x7fff202c96d0 bp 0x7ffee41a4570 sp 0x7ffee41a4560 T1126809)
==86053==The signal is caused by a READ memory access.
    #0 std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) <null>:2 (libc++.1.dylib:x86_64+0x136d0)
    #1 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) ostream:726 (el_bug:x86_64+0x1000098a7)
    #2 std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) ostream:869 (el_bug:x86_64+0x100009703)
    #3 el::base::MessageBuilder::operator<<(char const*) easylogging++.h:2926 (el_bug:x86_64+0x100009617)
    #4 el::base::Writer& el::base::Writer::operator<<<char [14]>(char const (&) [14]) easylogging++.h:3243 (el_bug:x86_64+0x100004d87)
    #5 main main.cpp:15 (el_bug:x86_64+0x10000481d)
    #6 start <null>:2 (libdyld.dylib:x86_64+0x15620)

==86053==Register values:
rax = 0x0000000000000000  rbx = 0x0000000000000000  rcx = 0x000000010bb013a4  rdx = 0x000000000000000d  
rdi = 0x00007ffee41a4688  rsi = 0x00007b5000000080  rbp = 0x00007ffee41a4570  rsp = 0x00007ffee41a4560  
 r8 = 0x0000000000000000   r9 = 0x0001800000000000  r10 = 0x0000000000000001  r11 = 0x0000000000000070  
r12 = 0x0000000000000000  r13 = 0x0000000000000000  r14 = 0x0000000000000000  r15 = 0x0000000000000000  
ThreadSanitizer can not provide additional info.
SUMMARY: ThreadSanitizer: SEGV (libc++.1.dylib:x86_64+0x136d0) in std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+0x10
==86053==ABORTING
[1]    86053 abort      ./el_bug