OTA binary coredump

ubuntu@ubuntu:~/ota/datalink/ota-primary$ sudo gdb bin/ota-primary core.323786
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type “show copying” and “show warranty” for details.
This GDB was configured as “x86_64-linux-gnu”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type “help”.
Type “apropos word” to search for commands related to “word”…
Reading symbols from bin/ota-primary…
[New LWP 323786]
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
Core was generated by `/home/ubuntu/ota/datalink/ota-primary/bin/ota-primary -c /home/ubuntu/ota/datal’.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055ddeed5b682 in boost::shared_ptrboost::log::v2s_mt_posix::core::operator-> (this=0x0) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/smart_ptr/shared_ptr.hpp:784
784 /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/smart_ptr/shared_ptr.hpp: No such file or directory.
(gdb) bt
#0 0x000055ddeed5b682 in boost::shared_ptrboost::log::v2s_mt_posix::core::operator-> (this=0x0) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/smart_ptr/shared_ptr.hpp:784
#1 0x000055ddeed5d567 in boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::severity_loggerota::common::log::LogLevel, boost::log::v2s_mt_posix::sources::single_thread_model, boost::log::v2s_mt_posix::sources::features<boost::log::v2s_mt_posix::sources::severityota::common::log::LogLevel > >::open_record<boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, ota::common::log::LogLevel> > > (this=0x0, args=…) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/log/sources/basic_logger.hpp:575
#2 0x000055ddeed56f57 in ota::common::log::Logger::Log_ (this=0x55ddef17be80 ota::common::log::global_logger_, level=ota::common::log::LogLevel::Debug, message=“Stream::DoCancel()”)
at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/log/platform/boost/boost_log.cpp:159
#3 0x000055ddeea3bd5c in ota::common::log::Logger::Log (this=0x55ddef17be80 ota::common::log::global_logger_, level=ota::common::log::LogLevel::Debug, message=“Stream::DoCancel()”)
at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/log.hpp:134
#4 0x000055ddeed58025 in ota::common::log::Debug (message=“Stream::DoCancel()”) at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/log/platform/boost/boost_log.cpp:308
#5 0x000055ddee8878e6 in ota::http::Stream::DoCancel (this=0x55de0fda3f50) at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/http/platform/beast/http.cpp:1295
#6 0x000055ddee88722e in ota::http::Stream::~Stream (this=0x55de0fda3f50, __in_chrg=) at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/http/platform/beast/http.cpp:1249
#7 0x000055ddeeaa6e4e in std::_Sp_counted_ptr<ota::http::Stream*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x55de0fdc65d0) at /usr/include/c++/11/bits/shared_ptr_base.h:348
#8 0x000055ddee75f5eb in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x55de0fdc65d0) at /usr/include/c++/11/bits/shared_ptr_base.h:168
#9 0x000055ddee75e819 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x7fffcd626610, __in_chrg=) at /usr/include/c++/11/bits/shared_ptr_base.h:705
#10 0x000055ddee878b22 in std::__shared_ptr<ota::http::Stream, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x7fffcd626608, __in_chrg=) at /usr/include/c++/11/bits/shared_ptr_base.h:1154
#11 0x000055ddee878b42 in std::shared_ptrota::http::Stream::~shared_ptr (this=0x7fffcd626608, __in_chrg=) at /usr/include/c++/11/bits/shared_ptr.h:122
#12 0x000055ddee88efae in ~(void) (this=0x7fffcd626600, __in_chrg=) at /mnt/hgfs/new-code/br_datalink/ota-primary/src/common/http/platform/beast/http.cpp:1923
#13 0x000055ddee89f91e in boost::asio::detail::binder1<ota::http::Server::AsyncAccept(ota::http::Server::StreamPtr)::<lambda(const std::error_code&)>, boost::system::error_code>::~binder1(void) (this=0x7fffcd626600,
in_chrg=) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/detail/bind_handler.hpp:139
#14 0x000055ddee89fa9d in boost::asio::detail::reactive_socket_accept_op<boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ip::tcp, ota::http::Server::AsyncAccept(ota::http::Server::StreamPtr)::<lambda(const std::error_code&)>, boost::asio::any_io_executor>::do_complete(void *, boost::asio::detail::operation *, const boost::system::error_code &, std::size_t) (owner=0x0, base=0x55de0fda44d0)
at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/detail/reactive_socket_accept_op.hpp:158
#15 0x000055ddee771379 in boost::asio::detail::scheduler_operation::destroy (this=0x55de0fda44d0) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/detail/scheduler_operation.hpp:45
#16 0x000055ddee7738a4 in boost::asio::detail::scheduler::shutdown (this=0x55de0fd99b60) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/detail/impl/scheduler.ipp:176
#17 0x000055ddee770c57 in boost::asio::detail::service_registry::shutdown_services (this=0x55de0fd99b10) at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/detail/impl/service_registry.ipp:44
#18 0x000055ddee771191 in boost::asio::execution_context::shutdown (this=0x55ddef171ea8 <ota::primary::Singletonota::primary::HttpServer::GetInstance()::instance
+40>)
at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/impl/execution_context.ipp:41
#19 0x000055ddee7741b6 in boost::asio::io_context::~io_context (this=0x55ddef171ea8 <ota::primary::Singletonota::primary::HttpServer::GetInstance()::instance
+40>, __in_chrg=)
at /home/ubuntu/code/ota-test/ota-third-party/x86_64_output/include/boost/asio/impl/io_context.ipp:58

When I was using HTTPServer, the program exited and I encountered a bug in the log coredump。

Hope this helps to solve this log bug.

Hi @PrimeQH,

Can you please share some context plus details, and how this possibly relates to Mender?

Greetz,
Josef

HTTPServer was built using the common/http.hpp library. When HTTPServer exited, a log null pointer bug was found. In the function void Stream::DoCancel() {

log::Debug(“Stream::DoCancel()”);

}, a logger_ null pointer appeared, and then in the function
void Logger::Log_(LogLevel level, const string &message) {
if (this->logger_ == nullptr) {
std::cerr << “Logger is not initialized or destroyed before use” << std::endl;
return;
}
BOOST_LOG_SEV(*this->logger_, level) << message;
}
, a coredump was generated when writing the log.

I currently add a null pointer check before writing to avoid the generation of coredump。
@TheYoctoJester

@PrimeQH okay… you’re writing a HTTPServer and are using boost, but that’s really the only thing I gather here.

Greetz,
Josef

HTTPServer has a logger object, and the global Logger object is used to write logs, and finally the program exits.