[LLVMbugs] [Bug 23266] New: raw_svector_ostream::pwrite problems
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 17 05:40:29 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23266
Bug ID: 23266
Summary: raw_svector_ostream::pwrite problems
Product: new-bugs
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: yaron.keren at gmail.com
CC: llvmbugs at cs.uiuc.edu, rafael.espindola at gmail.com
Classification: Unclassified
Hi Rafael,
Try adding this to the raw_pwrite_stream_test.cpp unit test, which will fail.
SmallString<16> Buffer4;
raw_svector_ostream OS4(Buffer4);
OS4.pwrite(Test.data(), Test.size(), 0);
OS4 << '4';
StringRef S4 = OS4.str();
EXPECT_EQ(S4, "4est");
While raw_fd_ostream::pwrite is careful to keep the current position so you can
do random r/w without disturbing the current stream position,
raw_svector_ostream::pwrite does not keep it, assuming the currrent position is
the vector size. Thus any write after pwrite will always occur at the end of
the vector and following the previous write(), inconsistent with
raw_svector_ostream::pwrite and programmer expectation.
Furthermore, the code
if (End > OS.size())
OS.resize(End);
must call resync() as it may modify the OS vector without updating the pointers
OutBufStart, OutBufEnd and OutBufCur.
These problems cause sometime corrupt ELF object file when written into a
raw_svector_ostream instead of raw_fd_ostream.
--
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/20150417/818b1bcd/attachment.html>
More information about the llvm-bugs
mailing list