我运行sudo valgrind --leak-check=full -v --track-origins=yes ./myprogram 结果是:
==31734== 1 errors in context 7 of 7:
==31734== Conditional jump or move depends on uninitialised value(s)
==31734== at 0x61CCCC: TlsProtocol::sendRecord(unsigned char const*, unsigned int, int, int, int, TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x61D32E: TlsProtocol::sendHandshakeMessages(DataBuffer&, int, int, TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x620B1C: TlsProtocol::sendClientHello(TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x6265E7: TlsProtocol::clientHandshake2(TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x627789: TlsProtocol::clientHandshake(char const*, int, TlsEndpoint&, unsigned int, SocketParams&, SharedCertChain*, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x616855: SChannelChilkat::connectImplicitSsl(char const*, int, bool, int, unsigned int, unsigned int, SystemCerts&, SocketParams&, LogBase&, bool&, SharedCertChain*) (in /home/me/src/myprogram)
==31734== by 0x56DDEB: Socket2::connect2(char const*, int, bool, bool, int, SystemCerts&, unsigned int, unsigned int, SocketParams&, LogBase&, bool&, int&, SharedCertChain*) (in /home/me/src/myprogram)
==31734== by 0x56E24F: Socket2::socket2Connect(char const*, int, bool, bool, int, SystemCerts&, unsigned int, unsigned int, SocketParams&, LogBase&, bool&, int&, SharedCertChain*, ClsSocksClient&, ClsHttpProxyClient*) (in /home/me/src/myprogram)
==31734== by 0x514FD9: Imap::connectToImapServer(char const*, int, StringBuffer&, SharedCertChain*, SystemCerts&, ClsSocksClient&, ClsHttpProxyClient*, LogBase&, ProgressMonitor*) (in /home/me/src/myprogram)
==31734== by 0x48BB69: ClsImap::Connect(XString&, ProgressEvent*) (in /home/me/src/myprogram)
==31734== by 0x454A5D: CkImap::Connect(char const*) (in /home/me/src/myprogram)
==31734== by 0x422C2E: EmailSensorAlertConnection::Connect(char const*, int, bool, char const*, char const*) (emailconnection.cpp:150)
==31734== Uninitialised value was created by a heap allocation
==31734== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31734== by 0x47F219: ClsImap::createNewCls() (in /home/me/src/myprogram)
==31734== by 0x4567EA: CkImap::CkImap() (in /home/me/src/myprogram)
==31734== by 0x422A13: EmailConnection::EmailConnection(std::string) (emailconnection.cpp:110)
==31734== by 0x41D364: IMAPConnectionFactory::getIMAPConnection() (imapconnectionfactory.cpp:46)
==31734== by 0x431362: main (myprogram.cpp:348)
==31734==
==31734== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)
myprogram.cpp 的一部分是:
bool connectRes = m_imap.Connect( server );//line 348
我试图找到未初始化的变量。它似乎在:ClsImap::createNewCls()。我用 grep 来搜索这个函数。此函数位于libchilkat-e/lib/libchilkat-9.5.0.a中。如何解决这个问题?似乎问题出在lib中。所以我什么都做不了?我对吗?