[Lldb-commits] [lldb] [lldb][windows] fix yaml2macho not loading file (PR #194909)

via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 29 09:50:19 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

<details>
<summary>Changes</summary>

This only triggers on Windows because of git using `autocrlf` by default:
- stat() returns the on-disk file size (including the `\r\n`).
- `fopen(file, "r")` opens in text mode, translating `\r\n` to `\n`.
- `fread(bug, sb.st_size, 1, file)` reads fewer bytes than expected due to the translation above.

Switching to `"rb"` fixes the issue.

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


1 Files Affected:

- (modified) lldb/tools/yaml2macho-core/yaml2macho.cpp (+1-1) 


``````````diff
diff --git a/lldb/tools/yaml2macho-core/yaml2macho.cpp b/lldb/tools/yaml2macho-core/yaml2macho.cpp
index 85979a37d1676..c29ae282d8571 100644
--- a/lldb/tools/yaml2macho-core/yaml2macho.cpp
+++ b/lldb/tools/yaml2macho-core/yaml2macho.cpp
@@ -72,7 +72,7 @@ int main(int argc, char **argv) {
     exit(1);
   }
 
-  FILE *input = fopen(InputFilename.c_str(), "r");
+  FILE *input = fopen(InputFilename.c_str(), "rb");
   if (!input) {
     fprintf(stderr, "Unable to open %s, exiting\n", InputFilename.c_str());
     exit(1);

``````````

</details>


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


More information about the lldb-commits mailing list