[llvm] r339027 - Fix raw_fd_ostream::write_impl hang due to an infinite loop with large output
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 8 13:20:37 PDT 2018
I wonder if you can use some existing LLVM tool where a small input (so we
don't have to bog everyone down with synciing/managing a large file in the
revision control system) that produces a sufficiently large output to
trigger the bug? & then take taht huge output through FileCheck to make
sure it's correct (but otherwise not produce lots of output to bog down
test machine's filesystems, etc).
- Dave
On Wed, Aug 8, 2018 at 4:40 AM Owen Reynolds <gbreynoo at gmail.com> wrote:
> Hi David,
>
> As this only affects large write attempts and a test failure would result
> in a hang, I was unsure how best to test this. Any suggestions would be
> appreciated.
>
> Thanks,
>
> Owen
>
> On Tue, Aug 7, 2018 at 4:55 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Any chance of a test case?
>>
>> On Mon, Aug 6, 2018 at 9:22 AM Owen Reynolds via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: gbreynoo
>>> Date: Mon Aug 6 09:21:41 2018
>>> New Revision: 339027
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=339027&view=rev
>>> Log:
>>> 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
>>>
>>> Modified:
>>> llvm/trunk/lib/Support/raw_ostream.cpp
>>>
>>> Modified: llvm/trunk/lib/Support/raw_ostream.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=339027&r1=339026&r2=339027&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/lib/Support/raw_ostream.cpp (original)
>>> +++ llvm/trunk/lib/Support/raw_ostream.cpp Mon Aug 6 09:21:41 2018
>>> @@ -613,10 +613,10 @@ void raw_fd_ostream::write_impl(const ch
>>> 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).
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180808/55ad8c31/attachment.html>
More information about the llvm-commits
mailing list