kevinrsa opened a new issue #342: URL: https://github.com/apache/rocketmq-client-cpp/issues/342
string terminator '\0' should be considered here: https://github.com/apache/rocketmq-client-cpp/blob/9008c14d9c34a4f0b4a67417000612348157027e/src/common/ClientRPCHook.cpp#L56 I use `valgrind` to run my program, it always prompts the following error. According to the source code, this should be because there is no string terminator `\0` ``` ==31201== Thread 17: ==31201== Invalid read of size 1 ==31201== at 0x4869EE1: vfprintf (in /usr/lib/libc-2.17.so) ==31201== by 0x4890E62: vsnprintf (in /usr/lib/libc-2.17.so) ==31201== by 0x43614A2: rocketmq::LogUtil::LogMessageFull(boost::log::v2s_mt_posix::trivial::severity_level, char const*, char const*, int, char const*, ...) (Logging.h:88) ==31201== by 0x436914C: rocketmq::ClientRPCHook::doBeforeRequest(std::string const&, rocketmq::RemotingCommand&) (ClientRPCHook.cpp:56) ==31201== by 0x44015FA: rocketmq::MQClientAPIImpl::callSignatureBeforeRequest(std::string const&, rocketmq::RemotingCommand&, rocketmq::SessionCredentials const&) (MQClientAPIImpl.cpp:181) ==31201== by 0x4404000: rocketmq::MQClientAPIImpl::sendHeartbeat(std::string const&, rocketmq::HeartbeatData*, rocketmq::SessionCredentials const&) (MQClientAPIImpl.cpp:273) ==31201== by 0x4357A1F: rocketmq::MQClientFactory::sendHeartbeatToAllBroker() (MQClientFactory.cpp:796) ==31201== by 0x4355D64: rocketmq::MQClientFactory::timerCB_sendHeartbeatToAllBroker(boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > > >) (MQClientFactory.cpp:838) ==31201== by 0x435C1E9: operator() (mem_fn_template.hpp:280) ==31201== by 0x435C1E9: operator()<boost::_mfi::mf2<void, rocketmq::MQClientFactory, boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > >, boost::_bi::list1<const boost::system::error_code&> > (bind.hpp:392) ==31201== by 0x435C1E9: operator()<const boost::system::error_code&> (bind.hpp:905) ==31201== by 0x435C1E9: operator() (bind_handler.hpp:47) ==31201== by 0x435C1E9: asio_handler_invoke<boost::asio::detail::binder1<boost::_bi::bind_t<void, boost::_mfi::mf2<void, rocketmq::MQClientFactory, boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > >, boost::_bi::list3<boost::_bi::value<rocketmq::MQClientFactory*>, boost::_bi::value<boost::system::error_code>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > > > >, boost::system::error_code> > (handler_invoke_hook.hpp:69) ==31201== by 0x435C1E9: invoke<boost::asio::detail::binder1<boost::_bi::bind_t<void, boost::_mfi::mf2<void, rocketmq::MQClientFactory, boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > >, boost::_bi::list3<boost::_bi::value<rocketmq::MQClientFactory*>, boost::_bi::value<boost::system::error_code>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > > > >, boost::system::error_code>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, rocketmq::MQClientFactory, boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > >, boost::_bi::list3<boost::_bi::value<rocketmq::MQClientFactory*>, boost::_bi::value<boost::system::error_code>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime> > > > > > (handler_invoke_helpers.hpp:37) ==31201== by 0x435C1E9: boost::asio::detail::wait_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, rocketmq::MQClientFactory, boost::system::error_code&, boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > > > >, boost::_bi::list3<boost::_bi::value<rocketmq::MQClientFactory*>, boost::_bi::value<boost::system::error_code>, boost::_bi::value<boost::shared_ptr<boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> > > > > > > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned int) (wait_handler.hpp:70) ==31201== by 0x435DCC8: complete (task_io_service_operation.hpp:38) ==31201== by 0x435DCC8: do_run_one (task_io_service.ipp:372) ==31201== by 0x435DCC8: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:149) ==31201== by 0x435677B: run (io_service.ipp:66) ==31201== by 0x435677B: rocketmq::MQClientFactory::startScheduledTask(bool) (MQClientFactory.cpp:893) ==31201== by 0x4358276: operator() (mem_fn_template.hpp:165) ==31201== by 0x4358276: operator()<boost::_mfi::mf1<void, rocketmq::MQClientFactory, bool>, boost::_bi::list0> (bind.hpp:313) ==31201== by 0x4358276: operator() (bind.hpp:893) ==31201== by 0x4358276: boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf1<void, rocketmq::MQClientFactory, bool>, boost::_bi::list2<boost::_bi::value<rocketmq::MQClientFactory*>, boost::_bi::value<bool> > > >::run() (thread.hpp:116) ==31201== Address 0x570f2f9 is 0 bytes after a block of size 337 alloc'd ==31201== at 0x402B2D8: malloc (vg_replace_malloc.c:299) ==31201== by 0x43721CF: rocketmq::MemoryBlock::setSize(int, bool) (dataBlock.cpp:110) ==31201== by 0x43ECD77: rocketmq::RemotingCommand::SetBody(char const*, int) (RemotingCommand.cpp:140) ==31201== by 0x4403FD2: rocketmq::MQClientAPIImpl::sendHeartbeat(std::string const&, rocketmq::HeartbeatData*, rocketmq::SessionCredentials const&) (MQClientAPIImpl.cpp:271) ==31201== by 0x4357A1F: rocketmq::MQClientFactory::sendHeartbeatToAllBroker() (MQClientFactory.cpp:796) ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
