diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h index 979f008b3170d..ddd7b56e82cef 100644 --- a/lldb/include/lldb/Core/ThreadSafeValue.h +++ b/lldb/include/lldb/Core/ThreadSafeValue.h @@ -42,6 +42,7 @@ template class ThreadSafeValue { // Call this if you have already manually locked the mutex using the // GetMutex() accessor + // coverity[missing_lock] void SetValueNoLock(const T &value) { m_value = value; } std::recursive_mutex &GetMutex() { return m_mutex; } diff --git a/lldb/source/Host/common/ProcessRunLock.cpp b/lldb/source/Host/common/ProcessRunLock.cpp index aee15779d9199..da59f40576978 100644 --- a/lldb/source/Host/common/ProcessRunLock.cpp +++ b/lldb/source/Host/common/ProcessRunLock.cpp @@ -24,6 +24,7 @@ ProcessRunLock::~ProcessRunLock() { bool ProcessRunLock::ReadTryLock() { ::pthread_rwlock_rdlock(&m_rwlock); if (!m_running) { + // coverity[missing_unlock] return true; } ::pthread_rwlock_unlock(&m_rwlock); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index dbf3afff7b0da..c69e7e41248fa 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6345,6 +6345,7 @@ static offset_t CreateAllImageInfosPayload( // The segment name in a Mach-O LC_SEGMENT/LC_SEGMENT_64 is char[16] and // is not guaranteed to be nul-terminated if all 16 characters are // used. + // coverity[buffer_size_warning] strncpy(seg_vmaddr.segname, name.AsCString(), sizeof(seg_vmaddr.segname)); seg_vmaddr.vmaddr = vmaddr; @@ -6740,6 +6741,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, // the right one, doesn't need to be nul terminated. // LC_NOTE name field is char[16] and is not guaranteed to be // nul-terminated. + // coverity[buffer_size_warning] strncpy(namebuf, lcnote->name.c_str(), sizeof(namebuf)); buffer.PutRawBytes(namebuf, sizeof(namebuf)); buffer.PutHex64(lcnote->payload_file_offset); diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h index 7f7c3ee90c6b8..4c52de99fde63 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h @@ -105,6 +105,7 @@ class RegisterInfoPOSIX_arm64 uint32_t ConfigureVectorLength(uint32_t sve_vq); bool VectorSizeIsValid(uint32_t vq) { + // coverity[unsigned_compare] if (vq >= eVectorQuadwordAArch64 && vq <= eVectorQuadwordAArch64SVEMax) return true; return false; diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp index 06c4e8ec68537..6190000f30690 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp @@ -126,6 +126,7 @@ size_t RegisterInfoPOSIX_riscv64::GetRegisterSetCount() const { size_t RegisterInfoPOSIX_riscv64::GetRegisterSetFromRegisterIndex( uint32_t reg_index) const { + // coverity[unsigned_compare] if (reg_index >= gpr_first_riscv && reg_index <= gpr_last_riscv) return GPRegSet; if (reg_index >= fpr_first_riscv && reg_index <= fpr_last_riscv) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index f750ad98b593e..1aa1ecc85069d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -304,7 +304,7 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo( response.PutChar(';'); } #endif // #if defined(__APPLE__) - + // coverity[unsigned_compare] if (g_default_packet_timeout_sec > 0) response.Printf("default_packet_timeout:%u;", g_default_packet_timeout_sec); diff --git a/lldb/tools/lldb-vscode/FifoFiles.cpp b/lldb/tools/lldb-vscode/FifoFiles.cpp index b97455ba953fb..6cde4a4930761 100644 --- a/lldb/tools/lldb-vscode/FifoFiles.cpp +++ b/lldb/tools/lldb-vscode/FifoFiles.cpp @@ -62,6 +62,13 @@ Expected FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) { line = buffer; })); if (future->wait_for(timeout) == std::future_status::timeout || !line) + // Indeed this is a leak, but it's intentional. "future" obj destructor + // will block on waiting for the worker thread to join. And the worker + // thread might be stuck in blocking I/O. Intentionally leaking the obj + // as a hack to avoid blocking main thread, and adding annotation to + // supress static code inspection warnings + + // coverity[leaked_storage] return createStringError(inconvertibleErrorCode(), "Timed out trying to get messages from the " + m_other_endpoint_name); @@ -79,6 +86,13 @@ Error FifoFileIO::SendJSON(const json::Value &json, done = true; })); if (future->wait_for(timeout) == std::future_status::timeout || !done) { + // Indeed this is a leak, but it's intentional. "future" obj destructor will + // block on waiting for the worker thread to join. And the worker thread + // might be stuck in blocking I/O. Intentionally leaking the obj as a hack + // to avoid blocking main thread, and adding annotation to supress static + // code inspection warnings" + + // coverity[leaked_storage] return createStringError(inconvertibleErrorCode(), "Timed out trying to send messages to the " + m_other_endpoint_name);