[compiler-rt] r226368 - [sanitizer] Adjust max read size in FlagHandlerInclude

Hal Finkel hfinkel at anl.gov
Fri Jan 16 19:31:43 PST 2015


Author: hfinkel
Date: Fri Jan 16 21:31:43 2015
New Revision: 226368

URL: http://llvm.org/viewvc/llvm-project?rev=226368&view=rev
Log:
[sanitizer] Adjust max read size in FlagHandlerInclude

Setting the maximum read size in FlagHandlerInclude to 2^15 might be a good
default, but causes the read to fail on systems with a page size larger than
that (ReadFileToBuffer(...) will fail if the maximum allowed size is less than
the value returned by GetPageSizeCached()). For example, on my PPC64/Linux
system, GetPageSizeCached() returns 2^16. In case the page size is larger, use
that instead.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=226368&r1=226367&r2=226368&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Fri Jan 16 21:31:43 2015
@@ -56,7 +56,8 @@ class FlagHandlerInclude : public FlagHa
     uptr data_mapped_size;
     int err;
     uptr len =
-      ReadFileToBuffer(value, &data, &data_mapped_size, kMaxIncludeSize, &err);
+      ReadFileToBuffer(value, &data, &data_mapped_size,
+                       Max(kMaxIncludeSize, GetPageSizeCached()), &err);
     if (!len) {
       Printf("Failed to read options from '%s': error %d\n", value, err);
       return false;





More information about the llvm-commits mailing list