diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h --- a/lldb/include/lldb/Core/ThreadSafeValue.h +++ b/lldb/include/lldb/Core/ThreadSafeValue.h @@ -42,6 +42,7 @@ // 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 --- a/lldb/source/Host/common/ProcessRunLock.cpp +++ b/lldb/source/Host/common/ProcessRunLock.cpp @@ -24,6 +24,7 @@ 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 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6345,6 +6345,7 @@ // 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 @@ // 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 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h @@ -105,6 +105,7 @@ 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 --- 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::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 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -304,7 +304,7 @@ 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 --- a/lldb/tools/lldb-vscode/FifoFiles.cpp +++ b/lldb/tools/lldb-vscode/FifoFiles.cpp @@ -62,6 +62,13 @@ 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 @@ 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);