[llvm-bugs] [Bug 37926] New: raw_fd_ostream::write_impl hang due to an infinite loop with large output

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 25 07:31:07 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37926

            Bug ID: 37926
           Summary: raw_fd_ostream::write_impl  hang due to an infinite
                    loop with large output
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: gbreynoo at gmail.com
                CC: llvm-bugs at lists.llvm.org

The Windows implementation of raw_fd_ostream::write_impl calls Windows write:

write(int _FileHandle, void const* _Buf, unsigned int _MaxCharCount)

ChunkSize is a size_t type (unsigned 64bit on x64) used for the argument
_MaxCharCount (unsigned 32bit). This means there is an integral demotion and
only the least significant bytes are retained. 

In the case of ChunkSize over 2^32 the least significant bytes are used and the
write performs successfully. Ptr and buffer size are then modified to reflect
this write, meaning the next ChunkSize will be a 64bit value with the least
significant bytes equalling 0.

When _MaxCharCount equals 0 Windows write fails, but as this is a recoverable
error  raw_fd_ostream::write_impl reattempts the write. The program is now
caught in an infinite loop.

This was seen on Windows 10 using Visual Studio 2015, x64 build.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180625/dab82e35/attachment-0001.html>


More information about the llvm-bugs mailing list