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

Coredump in cli::detail::Session::Disconnect() #176

Closed
Dup4 opened this issue Dec 30, 2022 · 3 comments
Closed

Coredump in cli::detail::Session::Disconnect() #176

Dup4 opened this issue Dec 30, 2022 · 3 comments

Comments

@Dup4
Copy link
Contributor

Dup4 commented Dec 30, 2022

  • cli: v2.0.2
  • boost: 1.78.0

I used the above configuration with cli, but a coredump occurred at runtime with the following stack information, some sensitive information has been handled.

#0  (inline)0x1f0a1f3 in cpputil::backtrace::(anonymous namespace)::signalHandler(int, siginfo_t*, void*) at /opt/tiger/bazel-buildfarm/default/operations/8d379db2-4128-4fb1-9dc4-bc4a80c55ac9/cpputil/backtrace/SignalHandler.cpp:127
#1  0x0 in (unknown) at :0
#2  0x34ec0 in gsignal at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/glibc/signal/../sysdeps/unix/sysv/linux/raise.c:51
#3  0x36030 in abort at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/glibc/stdlib/abort.c:79
#4  0x94972 in __gnu_cxx::__verbose_terminate_handler() [clone .cold.1] at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#5  0x9a8d5 in __cxxabiv1::__terminate(void (*)()) at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
#6  0x9a910 in std::terminate() at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
#7  0x9ab42 in __cxa_throw at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
#8  0x3215357 in void boost::throw_exception<boost::system::system_error>(boost::system::system_error const&) at /opt/tiger/bazel-buildfarm/default/operations/f959d280-2dd3-47c4-a9ff-693ae49b2567/cpp3rdlib/boost/include/boost/throw_exception.hpp:162
#9  0x33c0deb in boost::asio::detail::do_throw_error(boost::system::error_code const&, char const*) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/impl/throw_error.ipp:38
#10  (inline)0x33c0deb in boost::asio::detail::throw_error(boost::system::error_code const&, char const*) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/throw_error.hpp:42
#11  (inline)0x33c0deb in boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>::shutdown(boost::asio::socket_base::shutdown_type) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/basic_socket.hpp:1676
#12  0x33bfe79 in cli::detail::Session::Disconnect() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/cli/include/cli/detail/server.h:57
#13  0x33b1db5 in std::function<void (std::ostream&)>::operator()(std::ostream&) const at /opt/tiger/typhoon-blade/gccs/x86_64-x86_64-gcc-830/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/std_function.h:687
#14  (inline)0x33b1db5 in cli::CliSession::Exit() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/cli/include/cli/cli.h:303
#15  0x33b2a8b in cli::detail::InputHandler::Keypressed(std::pair<cli::detail::KeyType, char>) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/cli/include/cli/detail/inputhandler.h:60
#16  (inline)0x33b2a8b in operator()<std::pair<cli::detail::KeyType, char> > at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/cli/include/cli/detail/inputhandler.h:52
#17  (inline)0x33b2a8b in std::_Function_handler<void (std::pair<cli::detail::KeyType, char>), cli::detail::InputHandler::InputHandler(cli::CliSession&, cli::detail::InputDevice&)::{lambda(auto:1)#1}>::_M_invoke(std::_Any_data const&, std::pair<cli::detail::KeyType, char>&&) at /opt/tiger/typhoon-blade/gccs/x86_64-x86_64-gcc-830/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/std_function.h:297
#18  0x33b29e7 in std::function<void (std::pair<cli::detail::KeyType, char>)>::operator()(std::pair<cli::detail::KeyType, char>) const at /opt/tiger/typhoon-blade/gccs/x86_64-x86_64-gcc-830/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/std_function.h:687
#19  (inline)0x33b29e7 in operator() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/cli/include/cli/detail/inputdevice.h:59
#20  (inline)0x33b29e7 in std::_Function_handler<void (), cli::detail::InputDevice::Notify(std::pair<cli::detail::KeyType, char>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at /opt/tiger/typhoon-blade/gccs/x86_64-x86_64-gcc-830/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/std_function.h:297
#21  0x33bab7b in std::function<void ()>::operator()() const at /opt/tiger/typhoon-blade/gccs/x86_64-x86_64-gcc-830/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/std_function.h:687
#22  (inline)0x33bab7b in boost::asio::detail::binder0<std::function<void ()> >::operator()() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/bind_handler.hpp:60
#23  (inline)0x33bab7b in void boost::asio::asio_handler_invoke<boost::asio::detail::binder0<std::function<void ()> > >(boost::asio::detail::binder0<std::function<void ()> >&, ...) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/handler_invoke_hook.hpp:88
#24  (inline)0x33bab7b in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder0<std::function<void ()> >, std::function<void ()> >(boost::asio::detail::binder0<std::function<void ()> >&, std::function<void ()>&) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/handler_invoke_helpers.hpp:54
#25  (inline)0x33bab7b in void boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder0<std::function<void ()> >, std::function<void ()> >(boost::asio::detail::binder0<std::function<void ()> >&, boost::asio::detail::binder0<std::function<void ()> >*) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/bind_handler.hpp:111
#26  (inline)0x33bab7b in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder0<std::function<void ()> >, boost::asio::detail::binder0<std::function<void ()> > >(boost::asio::detail::binder0<std::function<void ()> >&, boost::asio::detail::binder0<std::function<void ()> >&) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/handler_invoke_helpers.hpp:54
#27  (inline)0x33bab7b in void boost::asio::detail::executor_function::complete<boost::asio::detail::binder0<std::function<void ()> >, std::allocator<void> >(boost::asio::detail::executor_function::impl_base*, bool) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/executor_function.hpp:116
#28  0x33b8ceb in boost::asio::detail::executor_function::operator()() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/executor_function.hpp:64
#29  (inline)0x33b8ceb in void boost::asio::asio_handler_invoke<boost::asio::detail::executor_function>(boost::asio::detail::executor_function&, ...) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/handler_invoke_hook.hpp:88
#30  (inline)0x33b8ceb in void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::executor_function, boost::asio::detail::executor_function>(boost::asio::detail::executor_function&, boost::asio::detail::executor_function&) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/handler_invoke_helpers.hpp:54
#31  (inline)0x33b8ceb in boost::asio::detail::executor_op<boost::asio::detail::executor_function, std::allocator<void>, boost::asio::detail::scheduler_operation>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/detail/executor_op.hpp:70
#32  0x3218565 in boost::asio::detail::scheduler_operation::complete(void*, boost::system::error_code const&, unsigned long) at /opt/tiger/bazel-buildfarm/default/operations/f959d280-2dd3-47c4-a9ff-693ae49b2567/cpp3rdlib/boost/include/boost/asio/detail/scheduler_operation.hpp:40
#33  (inline)0x3218565 in boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) at /opt/tiger/bazel-buildfarm/default/operations/f959d280-2dd3-47c4-a9ff-693ae49b2567/cpp3rdlib/boost/include/boost/asio/detail/impl/scheduler.ipp:492
#34  0x3218033 in boost::asio::detail::scheduler::run(boost::system::error_code&) at /opt/tiger/bazel-buildfarm/default/operations/f959d280-2dd3-47c4-a9ff-693ae49b2567/cpp3rdlib/boost/include/boost/asio/detail/impl/scheduler.ipp:210
#35  0x33aef46 in boost::asio::io_context::run() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/cpp3rdlib/boost/include/boost/asio/impl/io_context.ipp:63
#36  0x33adb3d in xxx::xxxxx::cli::CLI::run() at /opt/tiger/bazel-buildfarm/default/operations/bc3b4bc4-b87c-40d8-a522-443120f95bab/xxx/src/xxx/cli/cli.cpp:54
#37  0xc3a6e in execute_native_thread_routine at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
#38  0x7ca8 in start_thread at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/glibc/nptl/pthread_create.c:486
#39  0xf276e in clone at /data00/jenkins_dir/workspace/toolchain/gcc8_x86_64/src/glibc/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I can roughly deduce that when cli::detail::Session::Disconnect() was executed, boost threw an exception, but it was not caught, so a core dump occurred.

virtual void Disconnect()
{
socket.shutdown(asiolib::ip::tcp::socket::shutdown_both);
socket.close();
}

So have we considered adding a try statement to cli::detail::Session::Disconnect()?

@Dup4
Copy link
Contributor Author

Dup4 commented Dec 31, 2022

cc @nolongerwait

@daniele77
Copy link
Owner

@Dup4 please, provide this information:

  1. which code you've been running (please, post a minimal example having the problem)
  2. which action caused the core dump (e.g., exiting the application or closing a telnet session...)

So have we considered adding a try statement to cli::detail::Session::Disconnect()?

I don't think that's the right solution: we must find what caused the exception in the first place.

@Dup4
Copy link
Contributor Author

Dup4 commented Jan 13, 2023

I've checked it out, because after the ioc object corresponding to the cli is destructured, there are still other threads accessing it, resulting in a coredump.

@Dup4 Dup4 closed this as completed Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants