[Lldb-commits] [lldb] [lldb][windows] fix 4-byte error-code read (PR #197177)

via lldb-commits lldb-commits at lists.llvm.org
Tue May 12 05:53:38 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

Reading `word_size` (8) bytes here would include 4 bytes of stack garbage past the struct and produce bogus error codes.

---
Full diff: https://github.com/llvm/llvm-project/pull/197177.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+4-4) 


``````````diff
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 9e11b66068381..c82841ab029aa 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -398,10 +398,10 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
   }
 
   if (!token) {
-    // XXX(compnerd) should we use the compiler to get the sizeof(unsigned)?
-    uint64_t error_code =
-        process->ReadUnsignedIntegerFromMemory(injected_result + 2 * word_size + sizeof(unsigned),
-                                               word_size, 0, status);
+    // ErrorCode is a 4-byte `unsigned` field in __lldb_LoadLibraryResult.
+    uint64_t error_code = process->ReadUnsignedIntegerFromMemory(
+        injected_result + 2 * word_size + sizeof(unsigned), sizeof(unsigned), 0,
+        status);
     if (status.Fail()) {
       error = Status::FromErrorStringWithFormat(
           "LoadLibrary error: could not read error status: %s",

``````````

</details>


https://github.com/llvm/llvm-project/pull/197177


More information about the lldb-commits mailing list