[PATCH] D48948: Fix raw_fd_ostream::write_impl hang due to an infinite loop with large output

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 26 06:22:35 PDT 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338027: Fix raw_fd_ostream::write_impl hang with large output (authored by jhenderson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48948?vs=156057&id=157476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48948

Files:
  llvm/trunk/lib/Support/raw_ostream.cpp


Index: llvm/trunk/lib/Support/raw_ostream.cpp
===================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp
+++ llvm/trunk/lib/Support/raw_ostream.cpp
@@ -613,10 +613,10 @@
   assert(FD >= 0 && "File already closed.");
   pos += Size;
 
-  // The maximum write size is limited to SSIZE_MAX because a write
-  // greater than SSIZE_MAX is implementation-defined in POSIX.
-  // Since SSIZE_MAX is not portable, we use SIZE_MAX >> 1 instead.
-  size_t MaxWriteSize = SIZE_MAX >> 1;
+  // The maximum write size is limited to INT32_MAX. A write
+  // greater than SSIZE_MAX is implementation-defined in POSIX,
+  // and Windows _write requires 32 bit input.
+  size_t MaxWriteSize = INT32_MAX;
 
 #if defined(__linux__)
   // It is observed that Linux returns EINVAL for a very large write (>2G).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48948.157476.patch
Type: text/x-patch
Size: 843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180726/9e95c586/attachment.bin>


More information about the llvm-commits mailing list