[PATCH] D47247: Fix unaligned memory access when reading INPUT_FILE_OFFSETS data

Raphael Isemann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 22:47:44 PDT 2018

teemperor created this revision.
teemperor added reviewers: rsmith, v.g.vassilev.

The blob data is unaligned, so we also should read it as such. Should fix the random failures with the sanitizer builds.

  rC Clang



Index: lib/Serialization/ASTReader.cpp
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -4811,7 +4811,8 @@
       unsigned NumInputFiles = Record[0];
       unsigned NumUserFiles = Record[1];
-      const uint64_t *InputFileOffs = (const uint64_t *)Blob.data();
+      const llvm::support::unaligned_uint64_t *InputFileOffs =
+          (const llvm::support::unaligned_uint64_t *)Blob.data();
       for (unsigned I = 0; I != NumInputFiles; ++I) {
         // Go find this input file.
         bool isSystemFile = I >= NumUserFiles;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47247.148158.patch
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180523/cba5bb9b/attachment.bin>

More information about the cfe-commits mailing list