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: unassignedb...@nondot.org
          Reporter: gbrey...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to