Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern Format Segfault #24

Closed
jwillikers opened this issue Apr 29, 2020 · 4 comments
Closed

Pattern Format Segfault #24

jwillikers opened this issue Apr 29, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@jwillikers
Copy link

Using the set_pattern function handler appears to cause a runtime crash.
A stack trace of the segmentation fault is below.
This occurs on GCC 9.1.1 on CentOS 7.
I'm using the recent commit eb56fe8, but it occurs on v1.2.0 as well.
The issue does not occur using Clang 9.0.1 on macOS 10.15 Catalina.
My program crashes on launch.
Perhaps it has to do with the QUILL_STRING macro?

#0  0x0000000000498114 in __gnu_cxx::__exchange_and_add (__mem=0x200543c, __val=-1) at /opt/rh/devtoolset-9/root/usr/include/c++/9/ext/atomicity.h:49
#1  0x00000000004981ab in __gnu_cxx::__exchange_and_add_dispatch (__mem=0x200543c, __val=-1) at /opt/rh/devtoolset-9/root/usr/include/c++/9/ext/atomicity.h:82
#2  0x00000000004a5340 in std::string::_Rep::_M_dispose (this=0x200542c, __a=...) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3311
#3  0x000000000049e39a in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x2122458, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3706
#4  0x000000000049bd6e in quill::detail::TimestampFormatter::~TimestampFormatter (this=0x2122418, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/detail/TimestampFormatter.h:29
#5  0x00000000004a8a34 in quill::PatternFormatter::~PatternFormatter (this=0x21221f0, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/PatternFormatter.h:188
#6  0x00000000004a8a86 in std::default_delete<quill::PatternFormatter>::operator() (this=0x2121608, __ptr=0x21221f0) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:81
#7  0x00000000004a166e in std::unique_ptr<quill::PatternFormatter, std::default_delete<quill::PatternFormatter> >::~unique_ptr (this=0x2121608 = {...}, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:289
#8  0x00000000004f84aa in quill::Handler::~Handler (this=0x2121600, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/handlers/Handler.h:29
#9  0x00000000004fd416 in quill::StreamHandler::~StreamHandler (this=0x2121600, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/handlers/StreamHandler.h:26
#10 0x00000000004fd432 in quill::StreamHandler::~StreamHandler (this=0x2121600, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/handlers/StreamHandler.h:26
#11 0x000000000050553a in std::default_delete<quill::StreamHandler>::operator() (this=0x2121670, __ptr=0x2121600) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:81
#12 0x000000000050345c in std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> >::~unique_ptr (this=0x2121670 = {...}, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:289
#13 0x000000000050b1dc in std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >::~pair (this=0x2121668, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/stl_pair.h:208
#14 0x000000000050b208 in __gnu_cxx::new_allocator<std::__detail::_Hash_node<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, true> >::destroy<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > > > (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56>, __p=0x2121668) at /opt/rh/devtoolset-9/root/usr/include/c++/9/ext/new_allocator.h:153
#15 0x0000000000509f6f in std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, true> > >::destroy<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > > > (__a=..., __p=0x2121668) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/alloc_traits.h:497
#16 0x00000000005085f9 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, true> > >::_M_deallocate_node (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56>, __n=0x2121660) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/hashtable_policy.h:2102
#17 0x0000000000507c24 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, true> > >::_M_deallocate_nodes (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56>, __n=0x0) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/hashtable_policy.h:2124
#18 0x0000000000505e06 in std::_Hashtable<std::string, std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, std::allocator<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > > >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::clear (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/hashtable.h:2028
#19 0x0000000000503d98 in std::_Hashtable<std::string, std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > >, std::allocator<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > > >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56>, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/hashtable.h:1352
#20 0x0000000000502324 in std::unordered_map<std::string, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> >, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, std::unique_ptr<quill::StreamHandler, std::default_delete<quill::StreamHandler> > > > >::~unordered_map (this=0x5794b8 <quill::detail::LogManagerSingleton::instance()::instance+56> = {...}, __in_chrg=<optimized out>) at /opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unordered_map.h:102
#21 0x0000000000502344 in quill::detail::HandlerCollection::~HandlerCollection (this=0x5794a0 <quill::detail::LogManagerSingleton::instance()::instance+32>, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/detail/HandlerCollection.h:24
#22 0x00000000005023b6 in quill::detail::LogManager::~LogManager (this=0x579480 <quill::detail::LogManagerSingleton::instance()::instance>, __in_chrg=<optimized out>) at _deps/quill-src/quill/include/quill/detail/LogManager.h:27
#23 0x00000000004ff350 in quill::detail::LogManagerSingleton::~LogManagerSingleton (this=0x579480 <quill::detail::LogManagerSingleton::instance()::instance>, __in_chrg=<optimized out>) at _deps/quill-src/quill/src/detail/LogManagerSingleton.cpp:9
#24 0x00007faa19fd2ce9 in __run_exit_handlers () from /lib64/libc.so.6
#25 0x00007faa19fd2d37 in exit () from /lib64/libc.so.6
#26 0x00007faa19fbb55c in __libc_start_main () from /lib64/libc.so.6
#27 0x00000000004761c9 in _start ()
@odygrd
Copy link
Owner

odygrd commented Apr 29, 2020

Can you please attach the code snippet that makes it crash from the start of main() ?

It looks like it is crashing when main is exiting from the call stack

@jwillikers
Copy link
Author

Here's the snippet:

  quill::start();

  quill::Handler *handler = quill::stdout_handler();
  handler->set_pattern(
      QUILL_STRING(
          "%(ascii_time) [%(process):%(thread)] %(filename):%(lineno) %(level_name) %(logger_name) - %(message)"),
      "%FT%T.%Qus%z%Z");
  quill::set_default_logger_handler(handler);

@odygrd
Copy link
Owner

odygrd commented Apr 29, 2020

Thanks! I can not reproduce on ubuntu with gcc 9.3.0 :(
I will install centos 7 with devtools 7 to try..

@odygrd odygrd closed this as completed in d9b19cc Apr 30, 2020
@odygrd
Copy link
Owner

odygrd commented Apr 30, 2020

Thanks for reporting this. It should be fixed in the latest commit. Please check and if you still have any issues let me know.

@odygrd odygrd added the bug Something isn't working label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants