summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorOwen Reynolds <gbreynoo@gmail.com>2018-08-06 16:21:41 +0000
committerOwen Reynolds <gbreynoo@gmail.com>2018-08-06 16:21:41 +0000
commita489d1115887067370e23a3b5d4af7a42c81aa0c (patch)
tree575c3f7028cd48cd2cccf884d4e5af86c6ac1807 /llvm/lib/Support/raw_ostream.cpp
parentc03642e9a86d9ed128676d5405a1906282d727ad (diff)
downloadbcm5719-llvm-a489d1115887067370e23a3b5d4af7a42c81aa0c.tar.gz
bcm5719-llvm-a489d1115887067370e23a3b5d4af7a42c81aa0c.zip
Fix raw_fd_ostream::write_impl hang due to an infinite loop with large output
On windows when raw_fd_ostream::write_impl calls write, a 32 bit input is required for character count. As a variable with size_t is used for this argument, on x64 integral demotion occurs. In the case of large files an infinite loop follows. See: https://bugs.llvm.org/show_bug.cgi?id=37926 This fix allows the output of files larger than the previous int32 limit. Differential Revision: https://reviews.llvm.org/D48948 llvm-svn: 339027
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 038ad00bd60..1dae469958f 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -613,10 +613,10 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
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).
OpenPOWER on IntegriCloud