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

Crash on beginning certain streams #73

Closed
cache-return opened this issue Sep 8, 2020 · 5 comments
Closed

Crash on beginning certain streams #73

cache-return opened this issue Sep 8, 2020 · 5 comments
Labels

Comments

@cache-return
Copy link

This is ncmpc 0.38. I pulled from git after commit fb34258. I can reliably reproduce by loading https://direct.radiofrance.fr/live/franceinter-midfi.mp3. I was unable to reproduce over SSH in a reasonable sized window, but it crashes on a very small screen (a 20x9 xterm) with high consistency.

--Backtrace follows--

#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0xb6bc2230 in __GI_abort () at abort.c:79
#2 0xb6bcfbb8 in __assert_fail_base (fmt=0xb6cd66b0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=0x98f14 "basic.IsDefined()", assertion@entry=0xb6f69cb0 "\001", file=0x98edc "../src/hscroll.cxx",
file@entry=0x990f4 <hscroll::Paint() const::PRETTY_FUNCTION> "void hscroll::Paint() const", line=66,
line@entry=3066914480,
function=function@entry=0x990f4 <hscroll::Paint() const::PRETTY_FUNCTION> "void hscroll::Paint() const")
at assert.c:92
#3 0xb6bcfc6c in __GI___assert_fail (assertion=0xb6f69cb0 "\001",
file=0x990f4 <hscroll::Paint() const::PRETTY_FUNCTION> "void hscroll::Paint() const", line=3066914480,
function=0x990f4 <hscroll::Paint() const::PRETTY_FUNCTION> "void hscroll::Paint() const") at assert.c:101
#4 0x00065b54 in hscroll::Paint (this=0xbee09390) at ../src/hscroll.cxx:66
#5 0x00065fcc in hscroll::TimerCallback (this=0xbee09390, error=...) at ../src/hscroll.cxx:32
#6 0x00066fc4 in std::__invoke_impl<void, void (hscroll::&)(boost::system::error_code const&) noexcept, hscroll&, boost::system::error_code const&>(std::__invoke_memfun_deref, void (hscroll::&)(boost::system::error_code const&) noexcept, hscroll&, boost::system::error_code const&) (__f=
@0xbee09070: (void (hscroll::)(class hscroll * const, const class boost::system::error_code &)) 0x65f94 <hscroll::TimerCallback(boost::system::error_code const&)>, __t=@0xbee09078: 0xbee09390, __args#0=...)
at /usr/include/c++/8/bits/invoke.h:73
#7 0x00066ef8 in std::__invoke<void (hscroll::
&)(boost::system::error_code const&) noexcept, hscroll*&, boost::system::error_code const&>(void (hscroll::&)(boost::system::error_code const&) noexcept, hscroll&, boost::system::error_code const&) (__fn=
@0xbee09070: (void (hscroll::)(class hscroll * const, const class boost::system::error_code &)) 0x65f94 <hscroll::TimerCallback(boost::system::error_code const&)>, __args#0=@0xbee09078: 0xbee09390, __args#1=...)
at /usr/include/c++/8/bits/invoke.h:95
#8 0x00066dd4 in std::_Bind<void (hscroll::
(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>::__call<void, boost::system::error_code const&, 0u, 1u>(std::tuple<boost::system::error_code const&>&&, std::_Index_tuple<0u, 1u>) (this=0xbee09070, __args=...) at /usr/include/c++/8/functional:400
#9 0x00066d50 in std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>::operator()<boost::system::error_code const&, void>(boost::system::error_code const&) (this=0xbee09070,
__args#0=...) at /usr/include/c++/8/functional:484
#10 0x00066d00 in boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>::operator()() (this=0xbee09070)
at /usr/include/boost/asio/detail/bind_handler.hpp:65
#11 0x00066cc4 in boost::asio::asio_handler_invoke<boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, ...) (function=...) at /usr/include/boost/asio/handler_invoke_hook.hpp:69
#12 0x00066ca4 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>, std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>&) (function=..., context=...) at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:37
#13 0x00066b24 in boost::asio::detail::handler_work<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::asio::system_executor>::complete<boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>&) (this=0xbee09084, function=..., handler=...)
at /usr/include/boost/asio/detail/handler_work.hpp:82
#14 0x0006680c in boost::asio::detail::wait_handler<std::_Bind<void (hscroll::(hscroll, std::_Placeholder<1>))(boost::system::error_code const&) noexcept> >::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned int) (owner=0x1964c90, base=0x196c450)
at /usr/include/boost/asio/detail/wait_handler.hpp:72
#15 0x00024a78 in boost::asio::detail::scheduler_operation::complete (this=0x196c450, owner=0x1964c90, ec=...,
bytes_transferred=0) at /usr/include/boost/asio/detail/scheduler_operation.hpp:40
#16 0x00027ed8 in boost::asio::detail::scheduler::do_run_one (this=0x1964c90, lock=..., this_thread=..., ec=...) at /usr/include/boost/asio/detail/impl/scheduler.ipp:401
#17 0x00027b00 in boost::asio::detail::scheduler::run (this=0x1964c90, ec=...) at /usr/include/boost/asio/detail/impl/scheduler.ipp:154
#18 0x0002814c in boost::asio::io_context::run (this=0xbee09190) at /usr/include/boost/asio/impl/io_context.ipp:62
#19 0x00023bc4 in Instance::Run (this=0xbee09190) at ../src/Instance.cxx:102
#20 0x00018e84 in main (argc=1, argv=0xbee09664) at ../src/Main.cxx:360

@MaxKellermann
Copy link
Member

I have seen this bug a few times, but could not reproduce it now. The fix I have just pushed hopefully fixes the problem (a similar change fixed a similar bug a while ago), but I'm not sure. Please check if the crash is gone now.

@cache-return
Copy link
Author

Thanks for the update. It still crashes as before. Here is the backtrace from the crash on the most recent build:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0xb6bbc230 in __GI_abort () at abort.c:79
#2  0xb6bc9bb8 in __assert_fail_base (fmt=0xb6cd06b0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x99ef0 "basic.IsDefined()", assertion@entry=0xb6f63cb0 "\001", file=0x99eb8 "../src/hscroll.cxx", 
    file@entry=0x9a0d0 <hscroll::Paint() const::__PRETTY_FUNCTION__> "void hscroll::Paint() const", line=66, 
    line@entry=3066889904, 
    function=function@entry=0x9a0d0 <hscroll::Paint() const::__PRETTY_FUNCTION__> "void hscroll::Paint() const")
    at assert.c:92
#3  0xb6bc9c6c in __GI___assert_fail (assertion=0xb6f63cb0 "\001", 
    file=0x9a0d0 <hscroll::Paint() const::__PRETTY_FUNCTION__> "void hscroll::Paint() const", line=3066889904, 
    function=0x9a0d0 <hscroll::Paint() const::__PRETTY_FUNCTION__> "void hscroll::Paint() const") at assert.c:101
#4  0x00065f34 in hscroll::Paint (this=0x167ca48) at ../src/hscroll.cxx:66
#5  0x000663ac in hscroll::TimerCallback (this=0x167ca48, error=...) at ../src/hscroll.cxx:32
#6  0x000673a4 in std::__invoke_impl<void, void (hscroll::*&)(boost::system::error_code const&) noexcept, hscroll*&, boost::system::error_code const&>(std::__invoke_memfun_deref, void (hscroll::*&)(boost::system::error_code const&) noexcept, hscroll*&, boost::system::error_code const&) (__f=
    @0xbeb91070: (void (hscroll::*)(class hscroll * const, const class boost::system::error_code &)) 0x66374 <hscroll::TimerCallback(boost::system::error_code const&)>, __t=@0xbeb91078: 0x167ca48, __args#0=...)
    at /usr/include/c++/8/bits/invoke.h:73
#7  0x000672d8 in std::__invoke<void (hscroll::*&)(boost::system::error_code const&) noexcept, hscroll*&, boost::system::error_code const&>(void (hscroll::*&)(boost::system::error_code const&) noexcept, hscroll*&, boost::system::error_code const&) (__fn=
    @0xbeb91070: (void (hscroll::*)(class hscroll * const, const class boost::system::error_code &)) 0x66374 <hscroll::TimerCallback(boost::system::error_code const&)>, __args#0=@0xbeb91078: 0x167ca48, __args#1=...)
    at /usr/include/c++/8/bits/invoke.h:95
#8  0x000671b4 in std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>::__call<void, boost::system::error_code const&, 0u, 1u>(std::tuple<boost::system::error_code const&>&&, std::_Index_tuple<0u, 1u>) (this=0xbeb91070, __args=...) at /usr/include/c++/8/functional:400
#9  0x00067130 in std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>::operator()<boost::system::error_code const&, void>(boost::system::error_code const&) (this=0xbeb91070, 
    __args#0=...) at /usr/include/c++/8/functional:484
#10 0x000670e0 in boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>::operator()() (this=0xbeb91070)
    at /usr/include/boost/asio/detail/bind_handler.hpp:65
#11 0x000670a4 in boost::asio::asio_handler_invoke<boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, ...) (function=...) at /usr/include/boost/asio/handler_invoke_hook.hpp:69
#12 0x00067084 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>, std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>&) (function=..., context=...) at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:37
#13 0x00066f04 in boost::asio::detail::handler_work<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::asio::system_executor>::complete<boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code> >(boost::asio::detail::binder1<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>, boost::system::error_code>&, std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept>&) (this=0xbeb91084, function=..., handler=...)
    at /usr/include/boost/asio/detail/handler_work.hpp:82
#14 0x00066bec in boost::asio::detail::wait_handler<std::_Bind<void (hscroll::*(hscroll*, std::_Placeholder<1>))(boost::system::error_code const&) noexcept> >::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned int) (owner=0x167ac90, base=0x1681f38)
    at /usr/include/boost/asio/detail/wait_handler.hpp:72
#15 0x00024ab0 in boost::asio::detail::scheduler_operation::complete (this=0x1681f38, owner=0x167ac90, ec=..., 
    bytes_transferred=0) at /usr/include/boost/asio/detail/scheduler_operation.hpp:40
--Type <RET> for more, q to quit, c to continue without paging--c
#16 0x00027f10 in boost::asio::detail::scheduler::do_run_one (this=0x167ac90, lock=..., this_thread=..., ec=...) at /usr/include/boost/asio/detail/impl/scheduler.ipp:401
#17 0x00027b38 in boost::asio::detail::scheduler::run (this=0x167ac90, ec=...) at /usr/include/boost/asio/detail/impl/scheduler.ipp:154
#18 0x00028184 in boost::asio::io_context::run (this=0xbeb91190) at /usr/include/boost/asio/impl/io_context.ipp:62
#19 0x00023bfc in Instance::Run (this=0xbeb91190) at ../src/Instance.cxx:102
#20 0x00018ebc in main (argc=1, argv=0xbeb91664) at ../src/Main.cxx:360

@MaxKellermann MaxKellermann reopened this Oct 7, 2020
@MaxKellermann
Copy link
Member

Sigh. OK, I still can't reproduce it. When you do, please type in gdb: f 4 and p *this, paste the output here.
What do you do when this triggers? Where is the cursor - on that radio station? Does it crash when you start playback with another client? (e.g. another ncmpc process)

@cache-return
Copy link
Author

Exactly what I have been doing today (works every time) Hit Enter/start on the France Inter stream, then hit Tab to switch windows. I was getting the same crash in other contexts, but I can't recall them at the moment.

Thread 1 "ncmpc" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) f 4
#4  0x00065f34 in hscroll::Paint (this=0xbec00390) at ../src/hscroll.cxx:66
66		assert(basic.IsDefined());
(gdb) p *this
$1 = {w = 0xa67618, basic = {separator = 0xbc458 <options+200> " *** ", text = "", buffer = "", max_offset = 99, 
    width = 0, offset = 93}, x = 4, y = 0, style = Style::STATUS, attr = 0, 
  timer = {<boost::asio::basic_io_object<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >, true>> = {
      service_ = 0xa66008, implementation_ = {<boost::asio::detail::noncopyable> = {<No data fields>}, expiry = {
          __d = {__r = 196642176324383}}, might_have_pending_waits = false, timer_data = {
          op_queue_ = {<boost::asio::detail::noncopyable> = {<No data fields>}, front_ = 0x0, back_ = 0x0}, 
          heap_index_ = 1, next_ = 0x0, prev_ = 0x0}}}, <No data fields>}}

@MaxKellermann
Copy link
Member

MaxKellermann commented Oct 8, 2020

I found it: a boost::asio timer cannot be canceled properly: https://www.boost.org/doc/libs/1_74_0/doc/html/boost_asio/reference/basic_waitable_timer/cancel/overload1.html

These handlers can no longer be cancelled, and therefore are passed an error code that indicates the successful completion of the wait operation.

I always thought canceled timers would still be invoked, but with operation_aborted, which is what ncmpc checks:

ncmpc/src/hscroll.cxx

Lines 26 to 29 in 6394fa5

hscroll::TimerCallback(const boost::system::error_code &error) noexcept
{
if (error)
return;

But that's not enough. Timers which are canceled "too late" will be invoked without an error condition, as the Boost documentation says.
I guess it's time to get rid of boost::asio. That's an annoying design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants