miker2 / flexi_config_reader

A flexible configuration format that supports templated tables and referencing of existing keys.
MIT License
3 stars 1 forks source link

thread safety issue traced to logger->log_history #139

Closed cgstathis closed 1 week ago

cgstathis commented 5 months ago

reader.h line 213 has a debug print that was triggered by

params.getValue<std::array<size_t, 2>>("foo")

That getValue call is apparently not thread safe because of the log print which writes to a shared log_history

    #7 0x1332bfe in std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~pair() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_iterator.h:2488:12
    #8 0x1332bfe in void std::destroy_at<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_construct.h:88:15
    #9 0x1332bfe in void std::allocator_traits<std::allocator<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::destroy<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(std::allocator<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/alloc_traits.h:537:4
    #10 0x1332bfe in std::deque<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<flexi_cfg::logger::Severity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::pop_front() /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_deque.h:1538:6
    #11 0x1332bfe in void flexi_cfg::logger::Logger::log<char const*>(flexi_cfg::logger::Severity, std::basic_string_view<char, std::char_traits<char> >, char const*&&) /proc/self/cwd/external/flexi_cfg/include/flexi_cfg/logger.h:37:20
    #12 0x15c4a81 in void flexi_cfg::logger::debug<char const*>(std::basic_string_view<char, std::char_traits<char> >, char const*&&) /proc/self/cwd/external/flexi_cfg/include/flexi_cfg/logger.h:89:22
    #13 0x15ca853 in void flexi_cfg::Reader::getValue<unsigned long, 2ul>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::array<unsigned long, 2ul>&) const /proc/self/cwd/external/flexi_cfg/include/flexi_cfg/reader.h:213:5
    #14 0x15abef5 in std::array<unsigned long, 2ul> flexi_cfg::Reader::getValue<std::array<unsigned long, 2ul> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const /proc/self/cwd/external/flexi_cfg/include/flexi_cfg/reader.h:106:3
jayv commented 1 week ago

Fixed by #147