Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Rare segfault on log::worst_unread #84

Open
tmplt opened this issue Apr 20, 2019 · 1 comment
Open

Rare segfault on log::worst_unread #84

tmplt opened this issue Apr 20, 2019 · 1 comment
Labels
bug fixed? Has this issue been resolved? tui this issue regards the text-based user-interface

Comments

@tmplt
Copy link
Owner

tmplt commented Apr 20, 2019

A rare race condition can be encountered when log::worst_unread() is called:

Python thread backtrace (segfault)
#0  0x00000000004f146a in bookwyrm::tui::screen::log::<lambda(const auto:1&, const auto:2&)>::operator()<std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> >, std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> > >(const std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> &, const std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> &) const (__closure=0x7f48f44e2160, a=..., b=...) at /home/tmplt/code/bookwyrm/src/tui/screens/log.cpp:142
#1  0x00000000004f14b8 in __gnu_cxx::__ops::_Iter_comp_iter<bookwyrm::tui::screen::log::worst_unread() const::<lambda(const auto:1&, const auto:2&)> >::operator()<__gnu_cxx::__normal_iterator<const std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> >*, std::vector<std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> > > >, __gnu_cxx::__normal_iterator<const std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> >*, std::vector<std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> > > > >(__gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >, __gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >) (this=0x7f48f44e2160, __it1=..., __it2=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/predefined_ops.h:143
#2  0x00000000004f153b in std::__max_element<__gnu_cxx::__normal_iterator<const std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> >*, std::vector<std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> > > >, __gnu_cxx::__ops::_Iter_comp_iter<bookwyrm::tui::screen::log::worst_unread() const::<lambda(const auto:1&, const auto:2&)> > >(__gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >, __gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >, __gnu_cxx::__ops::_Iter_comp_iter<bookwyrm::tui::screen::log::worst_unread() const::<lambda(const auto:1&, const auto:2&)> >) (__first=..., __last=..., __comp=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/stl_algo.h:5653
#3  0x00000000004f1387 in std::max_element<__gnu_cxx::__normal_iterator<const std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> >*, std::vector<std::pair<const bookwyrm::core::log_level, const std::__cxx11::basic_string<char> > > >, bookwyrm::tui::screen::log::worst_unread() const::<lambda(const auto:1&, const auto:2&)> >(__gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >, __gnu_cxx::__normal_iterator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const*, std::vector<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const>, std::allocator<std::pair<bookwyrm::core::log_level const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> > > >, bookwyrm::tui::screen::log::<lambda(const auto:1&, const auto:2&)>) (
    __first=..., __last=..., __comp=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/stl_algo.h:5705
#4  0x00000000004f0ea6 in bookwyrm::tui::screen::log::worst_unread (this=0x24cb5d0)
    at /home/tmplt/code/bookwyrm/src/tui/screens/log.cpp:142
#5  0x00000000004e5670 in bookwyrm::tui::tui::update (this=0x24eb280) at /home/tmplt/code/bookwyrm/src/tui/tui.cpp:33
#6  0x00000000004e5971 in bookwyrm::tui::tui::log (this=0x24eb280, level=bookwyrm::core::log_level::err, message=...)
    at /home/tmplt/code/bookwyrm/src/tui/tui.cpp:60
#7  0x00007f48f45f00b9 in bookwyrm::core::plugin_handler::log (this=0x23e8d80, lvl=bookwyrm::core::log_level::err, msg=...)
    at /home/tmplt/code/bookwyrm/src/core/plugin_handler.cpp:289
#8  0x00007f48f45c01c0 in detail::log_wrapper::error (this=0x7f48ec002ac0, msg=...)
    at /home/tmplt/code/bookwyrm/src/core/bindings/python.cpp:20
#9  0x00007f48f45d0ffb in pybind11::cpp_function::cpp_function<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}::operator()(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (__closure=0x253b868, c=0x7f48ec002ac0, args#0=...) at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/pybind11.h:74
#10 0x00007f48f45e5b35 in pybind11::detail::argument_loader<detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>::call_impl<void, pybind11::cpp_function::cpp_function<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&, 0ul, 1ul, pybind11::detail::void_type>(pybind11::cpp_function::cpp_function<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&, std::integer_sequence<unsigned long, 0ul, 1ul>, pybind11::detail::void_type&&) (this=0x7f48f44e24f0, f=...) at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/cast.h:1931
#11 0x00007f48f45e070e in pybind11::detail::argument_loader<detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>::call<void, pybind11::detail::void_type, pybind11::cpp_function::cpp_function<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&>(pybind11::cpp_function::cpp_function<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&) && (this=0x7f48f44e24f0, f=...)
    at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/cast.h:1913
#12 0x00007f48f45d8536 in void pybind11::cpp_function::initialize<pybind11::cpp_function::initialize<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}, void, detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(pybind11::cpp_function::initialize<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&&, void (*)(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call) const (__closure=0x0, call=...)
    at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/pybind11.h:155
#13 0x00007f48f45d874a in void pybind11::cpp_function::initialize<pybind11::cpp_function::initialize<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}, void, detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(pybind11::cpp_function::initialize<void, detail::log_wrapper, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(void (detail::log_wrapper::*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}&&, void (*)(detail::log_wrapper*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call) ()
    at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/pybind11.h:133
#14 0x00007f48f45ba17b in pybind11::cpp_function::dispatcher (self=0x7f48f4b34060, args_in=0x7f48f4b2e4c8, kwargs_in=0x0)
    at /home/tmplt/code/bookwyrm/lib/pybind11/include/pybind11/pybind11.h:620
#15 0x00007f48fff158ba in _PyCFunction_FastCallDict ()
   from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#16 0x00007f48fffa3b99 in call_function () from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#17 0x00007f48fffa8ef1 in _PyEval_EvalFrameDefault ()
   from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#18 0x00007f48fffa3a3a in _PyEval_EvalCodeWithName ()
   from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#19 0x00007f48fffa409e in PyEval_EvalCodeEx () from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#20 0x00007f48ffede475 in function_call () from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#21 0x00007f48ffeab158 in PyObject_Call () from /nix/store/hy65mn4wjswqih75gfr6g4q3xgqdm325-python3-3.6.6/lib/libpython3.6m.so.1.0
#22 0x00000000004b6bca in bookwyrm::core::plugin_handler::python_module_runner (this=0x23e8d80, module=...)
    at /home/tmplt/code/bookwyrm/src/core/plugin_handler.cpp:186
#23 0x00000000004c4c77 in std::__invoke_impl<void, void (bookwyrm::core::plugin_handler::*)(pybind11::module), bookwyrm::core::plugin_handler*, pybind11::module> (__f=
    @0x245c478: (void (bookwyrm::core::plugin_handler::*)(bookwyrm::core::plugin_handler * const, pybind11::module)) 0x4b6a0e <bookwyrm::core::plugin_handler::python_module_runner(pybind11::module)>, __t=@0x245c470: 0x23e8d80, __args#0=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/invoke.h:73
#24 0x00000000004c35f9 in std::__invoke<void (bookwyrm::core::plugin_handler::*)(pybind11::module), bookwyrm::core::plugin_handler*, pybind11::module> (__fn=
    @0x245c478: (void (bookwyrm::core::plugin_handler::*)(bookwyrm::core::plugin_handler * const, pybind11::module)) 0x4b6a0e <bookwyrm::core::plugin_handler::python_module_runner(pybind11::module)>, __args#0=@0x245c470: 0x23e8d80, __args#1=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/invoke.h:95
#25 0x00000000004c670d in std::thread::_Invoker<std::tuple<void (bookwyrm::core::plugin_handler::*)(pybind11::module), bookwyrm::core::plugin_handler*, pybind11::module> >::_M_invoke<0ul, 1ul, 2ul> (this=0x245c468)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/thread:234
#26 0x00000000004c66a7 in std::thread::_Invoker<std::tuple<void (bookwyrm::core::plugin_handler::*)(pybind11::module), bookwyrm::core::plugin_handler*, pybind11::module> >::operator() (this=0x245c468)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/thread:243
#27 0x00000000004c6686 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (bookwyrm::core::plugin_handler::*)(pybind11::module), bookwyrm::core::plugin_handler*, pybind11::module> > >::_M_run (this=0x245c460)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/thread:186
#28 0x00007f48ff6ebedf in ?? () from /nix/store/zk5zj2307zxaq7dx585yia3dn5k4qlsl-gcc-7.3.0-lib/lib/libstdc++.so.6
#29 0x00007f48fee675a7 in start_thread () from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libpthread.so.0
#30 0x00007f48feb9e22f in clone () from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libc.so.6
Main thread backtrace (waiting for mutex)
#0  0x00007f48fee7086c in __lll_lock_wait () from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libpthread.so.0
#0  0x00007f48fee7086c in __lll_lock_wait () from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libpthread.so.0
#1  0x00007f48fee69b65 in pthread_mutex_lock () from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libpthread.so.0
#2  0x00000000004b4f99 in __gthread_mutex_lock (__mutex=0x24eb2a0)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:748
#3  0x00000000004b8d16 in std::mutex::lock (this=0x24eb2a0)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/std_mutex.h:103
#4  0x00000000004bcd9e in std::lock_guard<std::mutex>::lock_guard (this=0x7ffd98c1bb40, __m=...)
    at /nix/store/vv4r320p5yd1k01kld62q1lppjxcswhb-gcc-7.3.0/include/c++/7.3.0/bits/std_mutex.h:162
#5  0x00000000004e55ff in bookwyrm::tui::tui::update (this=0x24eb280) at /home/tmplt/code/bookwyrm/src/tui/tui.cpp:29
#6  0x00000000004e5971 in bookwyrm::tui::tui::log (this=0x24eb280, level=bookwyrm::core::log_level::err, message=...)
    at /home/tmplt/code/bookwyrm/src/tui/tui.cpp:60
#7  0x00000000004b79f9 in bookwyrm::core::plugin_handler::set_frontend (this=0x23e8d80, fe=...)
    at /home/tmplt/code/bookwyrm/src/core/plugin_handler.cpp:304
#8  0x0000000000410985 in main (argc=3, argv=0x7ffd98c1c4b8) at /home/tmplt/code/bookwyrm/src/main.cpp:223

@tmplt tmplt added bug tui this issue regards the text-based user-interface labels Apr 20, 2019
@tmplt
Copy link
Owner Author

tmplt commented Apr 22, 2019

Could 06ba687 possibly have resolved this?

@tmplt tmplt added the fixed? Has this issue been resolved? label Jul 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed? Has this issue been resolved? tui this issue regards the text-based user-interface
Projects
None yet
Development

No branches or pull requests

1 participant