think it clear: const, char, format

本文探讨了通过使用const关键字、unsigned char类型及简洁的if条件判断等方法来提高代码质量和可读性的具体实践。

写出糟糕的代码会带来糟糕的感觉和生活,尽管它运行的很好。

有时候我们面临着多种选择,这样也可,那样也可,但是哪一个才是那最精准,带着脆响的一投呢? 

今天遇到几个值得斟酌,需要think it clear的问题:

1, const:

void func( type* arg);

看到这句话我们脑海里闪现这样一些信息:

a, 这是用指针传递参数来代替整个类型的复制

b, 这个arg指向的内容可能会被改变

但是如果其实我们并不改变,那么这个声明就没有最确切的表达意思,下面就非常确切

void func(const type* arg);
   class type
   {
     public:
         const int* mMember;
   };

----不仅进了球,而且很脆的空心,读代码和写代码的人都感到很享受。

2, char and unsigned char

在表述字符的时候,用unsigned char更加合理

3, if

bool judge()
{
   
if(a)
   
{
       
if(b)
       
{
              
return true;
        }
else
        
{
              
return false;
        }

   }
else
   
{
        
return false;
    }

}

这个也的确是对的写法,但是无论自己写起来还是别人读起来,真是混乱的格式,不如改成:

bool judge()
{
if(a==false)
   
return false;
if(b==false)
   
return false;
if(...)
....;
   
return true;
}

这样层层筛选的意思就表达的十分确切

出现了链接错误: ld.lld: error: undefined symbol: webrtc::NetEq::Config::Config() >>> referenced by test1.cpp:115 (packages/apps/zorro/neteq/test1.cpp:115) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::CreateBuiltinAudioDecoderFactory() >>> referenced by test1.cpp:120 (packages/apps/zorro/neteq/test1.cpp:120) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::DefaultNetEqFactory::DefaultNetEqFactory() >>> referenced by test1.cpp:123 (packages/apps/zorro/neteq/test1.cpp:123) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::DefaultNetEqFactory::CreateNetEq(webrtc::NetEq::Config const&, rtc::scoped_refptr<webrtc::AudioDecoderFactory> const&, webrtc::Clock*) const >>> referenced by test1.cpp:124 (packages/apps/zorro/neteq/test1.cpp:124) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::DefaultNetEqFactory::~DefaultNetEqFactory() >>> referenced by test1.cpp:132 (packages/apps/zorro/neteq/test1.cpp:132) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::NetEq::Config::~Config() >>> referenced by test1.cpp:132 (packages/apps/zorro/neteq/test1.cpp:132) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: rtc::webrtc_checks_impl::FatalLog(char const*, int, char const*, rtc::webrtc_checks_impl::CheckArgType const*, ...) >>> referenced by checks.h:254 (packages/apps/zorro/neteq/include/rtc_base/checks.h:254) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::DefaultNetEqFactory::~DefaultNetEqFactory() >>> referenced by test1.cpp:132 (packages/apps/zorro/neteq/test1.cpp:132) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::NetEq::Config::~Config() >>> referenced by test1.cpp:132 (packages/apps/zorro/neteq/test1.cpp:132) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(CreateNetEq(webrtc::Clock*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::SdpAudioFormat(std::__1::basic_string_view<char, std::__1::char_traits<char> >, int, unsigned long, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >&&) >>> referenced by test1.cpp:140 (packages/apps/zorro/neteq/test1.cpp:140) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::~SdpAudioFormat() >>> referenced by test1.cpp:138 (packages/apps/zorro/neteq/test1.cpp:138) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::SdpAudioFormat(std::__1::basic_string_view<char, std::__1::char_traits<char> >, int, unsigned long) >>> referenced by test1.cpp:145 (packages/apps/zorro/neteq/test1.cpp:145) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::~SdpAudioFormat() >>> referenced by test1.cpp:143 (packages/apps/zorro/neteq/test1.cpp:143) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::SdpAudioFormat(std::__1::basic_string_view<char, std::__1::char_traits<char> >, int, unsigned long) >>> referenced by test1.cpp:150 (packages/apps/zorro/neteq/test1.cpp:150) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::~SdpAudioFormat() >>> referenced by test1.cpp:148 (packages/apps/zorro/neteq/test1.cpp:148) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::~SdpAudioFormat() >>> referenced by test1.cpp:0 (packages/apps/zorro/neteq/test1.cpp:0) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::SdpAudioFormat::~SdpAudioFormat() >>> referenced by test1.cpp:138 (packages/apps/zorro/neteq/test1.cpp:138) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(RegisterCodec(webrtc::NetEq*)) ld.lld: error: undefined symbol: webrtc::RTPHeader::RTPHeader() >>> referenced by test1.cpp:156 (packages/apps/zorro/neteq/test1.cpp:156) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(ProcessRtpPacket(webrtc::NetEq*, webrtc::RtpPacket const&)) ld.lld: error: undefined symbol: rtc::webrtc_logging_impl::Log(rtc::webrtc_logging_impl::LogArgType const*, ...) >>> referenced by logging.h:398 (packages/apps/zorro/neteq/include/rtc_base/logging.h:398) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(ProcessRtpPacket(webrtc::NetEq*, webrtc::RtpPacket const&)) ld.lld: error: undefined symbol: rtc::LogMessage::IsNoop(rtc::LoggingSeverity) >>> referenced by logging.h:545 (packages/apps/zorro/neteq/include/rtc_base/logging.h:545) >>> out/target/product/rk3399_Android10/obj/EXECUTABLES/neteq_rtpplay_intermediates/test1.o:(bool rtc::LogMessage::IsNoop<(rtc::LoggingSeverity)2>()) ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors) clang-9: error: linker command failed with exit code 1 (use -v to see invocation) 10:53:28 ninja failed with: exit status 1
08-03
#define LOG_TAG "CallStack" #include <utils/Printer.h> #include <utils/Errors.h> #include <log/log.h> #include <unwindstack/AndroidUnwinder.h> #define CALLSTACK_WEAK // Don't generate weak definitions. #include <utils/CallStack.h> namespace android { CallStack::CallStack() { } CallStack::CallStack(const char* logtag, int32_t ignoreDepth) { this->update(ignoreDepth+1); this->log(logtag); } CallStack::~CallStack() { } void CallStack::update(int32_t ignoreDepth, pid_t tid) { if (ignoreDepth < 0) { ignoreDepth = 0; } mFrameLines.clear(); unwindstack::AndroidLocalUnwinder unwinder; unwindstack::AndroidUnwinderData data; std::optional<pid_t> tid_val; if (tid != -1) { tid_val = tid; } if (!unwinder.Unwind(tid_val, data)) { ALOGW("%s: Failed to unwind callstack: %s", __FUNCTION__, data.GetErrorString().c_str()); } for (size_t i = ignoreDepth; i < data.frames.size(); i++) { auto& frame = data.frames[i]; frame.num -= ignoreDepth; mFrameLines.push_back(String8(unwinder.FormatFrame(frame).c_str())); } } void CallStack::log(const char* logtag, android_LogPriority priority, const char* prefix) const { LogPrinter printer(logtag, priority, prefix, /*ignoreBlankLines*/false); print(printer); } void CallStack::dump(int fd, int indent, const char* prefix) const { FdPrinter printer(fd, indent, prefix); print(printer); } String8 CallStack::toString(const char* prefix) const { String8 str; String8Printer printer(&str, prefix); print(printer); return str; } void CallStack::print(Printer& printer) const { for (size_t i = 0; i < mFrameLines.size(); i++) { printer.printLine(mFrameLines[i].c_str()); } } // The following four functions may be used via weak symbol references from libutils. // Clients assume that if any of these symbols are available, then deleteStack() is. // Apple and Windows does not support this, so only compile on other platforms. #if !defined(__APPLE__) && !defined(_WIN32) CallStack::CallStackUPtr CallStack::getCurrentInternal(int ignoreDepth) { CallStack::CallStackUPtr stack(new CallStack()); stack->update(ignoreDepth + 1); return stack; } void CallStack::logStackInternal(const char* logtag, const CallStack* stack, android_LogPriority priority) { stack->log(logtag, priority); } String8 CallStack::stackToStringInternal(const char* prefix, const CallStack* stack) { return stack->toString(prefix); } void CallStack::deleteStack(CallStack* stack) { delete stack; } #endif // !defined(__APPLE__) && !defined(_WIN32) }; // namespace android 帮我解析一下这整个代码并说出各个函数的用途
10-30
#pragma once #include "message.hpp" #include <vector> #include <assert.h> #include <iostream> #include <memory> #include <sstream> #include <utility> #include <cstdlib> namespace Log { class FormatItem { public: using ptr = std::shared_ptr<FormatItem>; //virtual ~FormatItem() {} virtual void format(std::ostream &out, const LogMsg &msg) = 0; }; class TimeFormatItem : public FormatItem { private: std::string _format; // 将时间戳转化成某种格式 public: TimeFormatItem(const std::string &format = "%H:%M:%S") : _format(format) { if (format.empty()) _format = "%H:%M:%S"; } void format(std::ostream &out, const LogMsg &msg) override { time_t t = msg._ctime; struct tm lt; localtime_r(&t, &lt); char tmp[128]; strftime(tmp, 127, _format.c_str(), &lt); out << tmp; } }; class CFileFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << msg._file; } }; class LevelFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { // level是自定义类型,这里我们要自己实现一个tostring out << LogLevel::tostring(msg._level); } }; class CLineFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << msg._line; } }; class NameFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << msg._name; } }; class MsgFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << msg._payload; } }; class ThreadFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << msg._tid; } }; class NlineFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << "\n"; } }; class TabFormatItem : public FormatItem { public: void format(std::ostream &out, const LogMsg &msg) override { out << "\t"; } }; class OtherFormatItem : public FormatItem { // 输出任意用户定义的字符串(可能是空格、符号、固定文本等)。 private: std::string _str; public: OtherFormatItem(std::string str = "") : _str(str) {} void format(std::ostream &out, const LogMsg &msg) override { out << _str; } }; class Formatter { // %d ⽇期 // %T 缩进 // %t 线程id // %p ⽇志级别 // %c ⽇志器名称 // %f ⽂件名 // %l ⾏号 // %m ⽇志消息 // %n 换 private: std::string _pattern; // 自定义的格式化样式 std::vector<FormatItem::ptr> _items; // 存储 实例化Item 的数组 public: using ptr = std::shared_ptr<Formatter>; Formatter(const std::string pattern = "[%d{%H:%M:%S}][%t][%p][%c][%f:%l] %m%n") : _pattern(pattern) { assert(parsePattern()); } void format(std::ostream &out, const LogMsg &msg) { for (auto &it : _items) { it->format(out, msg); } } std::string format(const LogMsg &msg) { std::stringstream ss; format(ss,msg); return ss.str(); } // %d ⽇期 // %T 缩进 // %t 线程id // %p ⽇志级别 // %c ⽇志器名称 // %f ⽂件名 // %l ⾏号 // %m ⽇志消息 // %n 换 //"[%d{%H:%M:%S}][%t][%p][%c][%f:%l] %m%n" FormatItem::ptr CreateItem(const std::string &key, const std::string &val) { if (key == "d") return std::make_shared<TimeFormatItem>(val); if (key == "T") return std::make_shared<TabFormatItem>(); if (key == "t") return std::make_shared<ThreadFormatItem>(); if (key == "p") return std::make_shared<LevelFormatItem>(); if (key == "c") return std::make_shared<NameFormatItem>(); if (key == "f") return std::make_shared<CFileFormatItem>(); if (key == "l") return std::make_shared<CLineFormatItem>(); if (key == "m") return std::make_shared<MsgFormatItem>(); if (key == "n") return std::make_shared<NlineFormatItem>(); if (key == "") return std::make_shared<OtherFormatItem>(val); std::cerr << "未知的格式化字符%" << key << "!!!" << std::endl; abort(); } private: // 解析pattern 是否合法性 bool parsePattern() { std::vector<std::pair<std::string, std::string>> arry; std::string key, val; size_t pos = 0; while (pos < _pattern.size()) // abcsd%%asd[%d{%H:%M:%S}][%t][%p][%c][%f:%l] { // 如果_pattern[pos] 不是‘%’ 则这些字符都不是格式化字符 if (_pattern[pos] != '%') { val.push_back(_pattern[pos]); pos++; continue; } // 如果 _pattern[pos] == '%' 我们需要判断 是否是 '%%' if (pos + 1 < _pattern.size() && _pattern[pos + 1] == '%') { val.push_back('%'); pos += 2; continue; } // 将用户自定的非格式化字符插入到arry中 if (!val.empty()) { arry.push_back(std::make_pair("", val)); val.clear(); // 清空val } // 如果是正常的格式化字符 我们需要判断是否存在子规则,%d{%H:%M:%S} pos++; // 这里指的是 % 之后的格式化字符 if (pos == _pattern.size()) { std::cerr << "%之后缺少格式化字符!!!" << std::endl; return false; } key.push_back(_pattern[pos]); pos++; if (pos < _pattern.size() && _pattern[pos] == '{') { pos++; while (pos < _pattern.size() && _pattern[pos] != '}') { val.push_back(_pattern[pos]); pos++; } // while循环 可能因为 pos 越界而退出,所以我们需要判断 if (pos == _pattern.size()) { std::cerr << "子规则'{}'匹配失败!!!" << std::endl; return false; } pos++; } arry.push_back(std::make_pair(key, val)); key.clear(); val.clear(); } for (auto &it : arry) { _items.push_back(CreateItem(it.first, it.second)); } return true; } }; } 解释一下
10-28
-------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-000-addr=192.168.1.27;_running=0 2025-10-03 10:43:29.019 [24138] LOG_DEBUG modbus_tcp connect 192.168.1.27:502 start... 2025-10-03 10:43:29.020 [24138] LOG_INFO modbus_tcp serveraddr is ip format -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 2025-10-03 10:43:29.238 [24140] LOG_DEBUG 192.168.1.27:502: tcp connect suc: 2025-10-03 10:43:29.238 [24140] LOG_INFO 192.168.1.27:502: tcp start rec data -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-000-addr=192.168.1.27;ret=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-111-addr=192.168.1.27;_process_thread=1 [2025-10-03 10:43:30] ModbusTCPInput::start conn_status: 3;collect_status:2;_running:1;_poll_thread:1 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 MQTT connecting -222- to tcp://192.168.1.27:1883 with _connected 0 -------------------------------------- Failed to start output processor -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 MQTT connecting -222- to tcp://192.168.1.27:1883 with _connected 0 Failed to start output processor GatewayManager::start()00: 1 Gateway manager started. Press Ctrl+C or Ctrl+Z to stop. -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 [2025-10-03 10:43:32] Initialized upload,logs and download directories [2025-10-03 10:43:32] Server started on port :8082 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 get- pathMoudle: collectconn collectconn:in Database opened: ./jcdz-db.db -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== SQL sql=:SELECT CollectConnNO, Name,ConnType,ProtocolType, Path,DnsIP,Port,Timeout,Memo,ConnStatus,ConnTime,CollectStatus,CollectTime,ChanCount,ComName,ComBaudRate,ComParityCheck,ComStopBit,RegDevName,RegDevId,RegMode,RegFactType,RegFactChan,RegFactNO FROM IOT_CollectConn_info; -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 [2025-10-03 10:43:35] GET /api/collectconn - Status: 200 - Remote: 192.168.20.27:61079 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 get- pathMoudle: collectconn collectconn:in stop ----: conn [2025-10-03 10:43:36] ModbusTCPInput::stop conn_status: 0;collect_status:5;_running:1;_poll_thread:1 ==24138== Thread 14: ==24138== Conditional jump or move depends on uninitialised value(s) ==24138== at 0x25B4A3: JCNetopTcpclient::Stop() (JCNetopTcpclient.cpp:293) ==24138== by 0x2466FF: ModbusTCPClient::disconnect() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x162DC3: ModbusTCPInput::stop() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168BF7: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== Uninitialised value was created by a heap allocation ==24138== at 0x4849013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x24608E: ModbusTCPClient::ModbusTCPClient(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16249E: ModbusTCPInput::ModbusTCPInput(InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x183FC0: void __gnu_cxx::new_allocator<ModbusTCPInput>::construct<ModbusTCPInput, InputConfig&>(ModbusTCPInput*, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x182F5D: void std::allocator_traits<std::allocator<ModbusTCPInput> >::construct<ModbusTCPInput, InputConfig&>(std::allocator<ModbusTCPInput>&, ModbusTCPInput*, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1817A7: std::_Sp_counted_ptr_inplace<ModbusTCPInput, std::allocator<ModbusTCPInput>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<InputConfig&>(std::allocator<ModbusTCPInput>, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17F945: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<ModbusTCPInput, std::allocator<ModbusTCPInput>, InputConfig&>(ModbusTCPInput*&, std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17DD45: std::__shared_ptr<ModbusTCPInput, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<ModbusTCPInput>, InputConfig&>(std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17BA86: std::shared_ptr<ModbusTCPInput>::shared_ptr<std::allocator<ModbusTCPInput>, InputConfig&>(std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x178230: std::shared_ptr<ModbusTCPInput> std::allocate_shared<ModbusTCPInput, std::allocator<ModbusTCPInput>, InputConfig&>(std::allocator<ModbusTCPInput> const&, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174553: std::shared_ptr<ModbusTCPInput> std::make_shared<ModbusTCPInput, InputConfig&>(InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x169B98: GatewayManager::createProcessors(std::vector<GatewayConfig, std::allocator<GatewayConfig> >&, bool) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== Invalid read of size 8 ==24138== at 0x145344: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::size() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174BED: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::vector(std::vector<GatewayConfig, std::allocator<GatewayConfig> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16A073: GatewayManager::getGateways() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168C18: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== Address 0xa0 is not stack'd, malloc'd or (recently) free'd ==24138== ==24138== ==24138== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==24138== Access not within mapped region at address 0xA0 ==24138== at 0x145344: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::size() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174BED: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::vector(std::vector<GatewayConfig, std::allocator<GatewayConfig> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16A073: GatewayManager::getGateways() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168C18: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== If you believe this happened as a result of a stack ==24138== overflow in your program's main thread (unlikely but ==24138== possible), you can try to increase the size of the ==24138== main thread stack using the --main-stacksize= flag. ==24138== The main thread stack size used in this run was 8388608. ==24138== ==24138== HEAP SUMMARY: ==24138== in use at exit: 485,052 bytes in 1,234 blocks ==24138== total heap usage: 3,183 allocs, 1,949 frees, 799,663 bytes allocated ==24138== ==24138== Thread 1: ==24138== 304 bytes in 1 blocks are possibly lost in loss record 403 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x26BC48: zsummer::log4z::ThreadHelper::start() (log4z.cpp:1145) ==24138== by 0x26D5CE: zsummer::log4z::LogerManager::start() (log4z.cpp:1490) ==24138== by 0x268BF0: JCCommuLib::JCCommuLib() (JCCommuLib.cpp:34) ==24138== by 0x268ECB: JCCommuLib::getInstance() (JCCommuLib.cpp:67) ==24138== by 0x19142B: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 404 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x2697F3: std::thread::thread<void (JCCommuLib::*)(), JCCommuLib*, void>(void (JCCommuLib::*&&)(), JCCommuLib*&&) (std_thread.h:143) ==24138== by 0x26950A: JCCommuLib::Run() (JCCommuLib.cpp:106) ==24138== by 0x191455: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 405 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4AD526D: Paho_thread_start (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x4AB8F14: MQTTAsync_connect (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x24FCAF: MQTTClientWrapper::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x167AB5: MQTTOutput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1683DE: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 406 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4AD526D: Paho_thread_start (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x4AB8F4A: MQTTAsync_connect (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x24FCAF: MQTTClientWrapper::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x167AB5: MQTTOutput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1683DE: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 407 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x173E3D: std::thread::thread<void (GatewayManager::*)(), GatewayManager*, void>(void (GatewayManager::*&&)(), GatewayManager*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1684B0: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 608 bytes in 2 blocks are possibly lost in loss record 472 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x17202D: std::thread::thread<void (ModbusTCPInput::*)(), ModbusTCPInput*, void>(void (ModbusTCPInput::*&&)(), ModbusTCPInput*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x162682: ModbusTCPInput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168330: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 608 bytes in 2 blocks are possibly lost in loss record 473 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x24731D: std::thread::thread<void (ModbusTCPClient::*)(), ModbusTCPClient*, void>(void (ModbusTCPClient::*&&)(), ModbusTCPClient*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2464FE: ModbusTCPClient::connect() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1626C9: ModbusTCPInput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168330: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 1,520 bytes in 5 blocks are possibly lost in loss record 544 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x206F09: std::thread::thread<httplib::ThreadPool::worker, , void>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F3D40: void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, httplib::ThreadPool::worker>(std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8DAE: void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, httplib::ThreadPool::worker>(std::allocator<std::thread>&, std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8EC9: void std::vector<std::thread, std::allocator<std::thread> >::_M_realloc_insert<httplib::ThreadPool::worker>(__gnu_cxx::__normal_iterator<std::thread*, std::vector<std::thread, std::allocator<std::thread> > >, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DB9FD: void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1968F9: httplib::ThreadPool::ThreadPool(unsigned long) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x19DB2D: httplib::Server::Server()::{lambda()#1}::operator()() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x208603: httplib::ThreadPool* std::__invoke_impl<httplib::ThreadPool*, httplib::Server::Server()::{lambda()#1}&>(std::__invoke_other, httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 3,040 bytes in 10 blocks are possibly lost in loss record 549 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x206F09: std::thread::thread<httplib::ThreadPool::worker, , void>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F3D40: void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, httplib::ThreadPool::worker>(std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8DAE: void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, httplib::ThreadPool::worker>(std::allocator<std::thread>&, std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DB9B7: void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1968F9: httplib::ThreadPool::ThreadPool(unsigned long) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x19DB2D: httplib::Server::Server()::{lambda()#1}::operator()() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x208603: httplib::ThreadPool* std::__invoke_impl<httplib::ThreadPool*, httplib::Server::Server()::{lambda()#1}&>(std::__invoke_other, httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F6A4D: std::enable_if<std::__and_<std::__not_<std::is_void<httplib::TaskQueue*> >, std::is_convertible<std::__invoke_result<httplib::Server::Server()::{lambda()#1}&>::type, httplib::TaskQueue*> >::value, httplib::TaskQueue*>::type std::__invoke_r<httplib::TaskQueue*, httplib::Server::Server()::{lambda()#1}&>(httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== LEAK SUMMARY: ==24138== definitely lost: 0 bytes in 0 blocks ==24138== indirectly lost: 0 bytes in 0 blocks ==24138== possibly lost: 7,296 bytes in 24 blocks ==24138== still reachable: 477,756 bytes in 1,210 blocks ==24138== of which reachable via heuristic: ==24138== length64 : 119,744 bytes in 438 blocks ==24138== suppressed: 0 bytes in 0 blocks ==24138== Reachable blocks (those to which a pointer was found) are not shown. ==24138== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==24138== ==24138== For lists of detected and suppressed errors, rerun with: -s ==24138== ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 0 from 0) Segmentation fault
10-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值