Did you confirm this fixes it?  Because i was just speculating :)<br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 17, 2017 at 6:01 AM Marco Castelluccio via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">marco-c updated this revision to Diff 119299.<br>
marco-c retitled this revision from "Use fopen instead of fdopen for opening GCDA files as fdopen seems to cause files to get corrupted" to "Use O_BINARY when opening GCDA file on Windows".<br>
marco-c edited the summary of this revision.<br>
marco-c added a comment.<br>
<br>
Replaced **fopen** with **fdopen** again, added O_BINARY when originally opening file with **open**.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D38984" rel="noreferrer" target="_blank">https://reviews.llvm.org/D38984</a><br>
<br>
Files:<br>
  lib/profile/GCDAProfiling.c<br>
<br>
<br>
Index: lib/profile/GCDAProfiling.c<br>
===================================================================<br>
--- lib/profile/GCDAProfiling.c<br>
+++ lib/profile/GCDAProfiling.c<br>
@@ -37,7 +37,10 @@<br>
 #ifndef MAP_FILE<br>
 #define MAP_FILE 0<br>
 #endif<br>
+#ifndef O_BINARY<br>
+#define O_BINARY 0<br>
 #endif<br>
+#endif<br>
<br>
 #if defined(__FreeBSD__) && defined(__i386__)<br>
 #define I386_FREEBSD 1<br>
@@ -238,17 +241,17 @@<br>
<br>
   /* Try just opening the file. */<br>
   new_file = 0;<br>
-  fd = open(filename, O_RDWR);<br>
+  fd = open(filename, O_RDWR | O_BINARY);<br>
<br>
   if (fd == -1) {<br>
     /* Try opening the file, creating it if necessary. */<br>
     new_file = 1;<br>
     mode = "w+b";<br>
-    fd = open(filename, O_RDWR | O_CREAT, 0644);<br>
+    fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);<br>
     if (fd == -1) {<br>
       /* Try creating the directories first then opening the file. */<br>
       __llvm_profile_recursive_mkdir(filename);<br>
-      fd = open(filename, O_RDWR | O_CREAT, 0644);<br>
+      fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);<br>
       if (fd == -1) {<br>
         /* Bah! It's hopeless. */<br>
         int errnum = errno;<br>
<br>
<br>
</blockquote></div>