public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65663] New: libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption
@ 2015-04-02 16:07 kkananen at gmail dot com
  2015-04-02 16:10 ` [Bug libstdc++/65663] " kkananen at gmail dot com
  2015-04-02 20:53 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: kkananen at gmail dot com @ 2015-04-02 16:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65663

            Bug ID: 65663
           Summary: libstdc++: writing mixed-size blocks through an
                    std::ofstream to a SMB 2.1 share produces file
                    corruption
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kkananen at gmail dot com

Created attachment 35216
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35216&action=edit
Preprocessed minimum-repro.ii

Basic description of the problem:
Application writing into a libstdc++ ofstream from a Mac OS X 10.9 or 10.10
host to a samba shared folder hosted on Windows 7/8/2008 Server (the
combination of OS X + Windows has to support SMB 2.1) can produce file
corruption.

Reproductions steps:
You need two PCs visible to each other in a network: 
  a. a Mac running OS X 10.9 or later
  b. a Windows 7, Windows Server 2008 R2 or later PC.

1. Share a test folder on the Windows PC so that it is visible for the Mac in 
  the network

2. Connect the Mac to the windows shared folder using the smb protocol:
  e.g. in OSX Finder, connect to server smb://name-of-windows-pc/name-of-share
  (the share should now be visible under /Volumes/name-of-share/)

3. Compile this application on the Mac against libstdc++
  e.g. apple clang 5.0:
    clang++ ./minimum-repro.cpp -stdlib=libstdc++ -o minimum-repro
       g++ (4.0 or later):
    g++ ./minimum-repro.cpp -o minimum-repro

4. Run the compiled app on the Mac, with a single argument, a path to a file on
the 
  network share:
  e.g. ./minimum-repro /Volumes/name-of-share/corruption-test.txt


The file will be written and it's contents read back and checked against the
reference - they will not match in contents, i.e. the file has been corrupted
on write.


The key to bug reproduction is to first write a small block of data (< 1022
bytes) and then a large block (> 0.5 MB) into an ofstream opened on the shared
folder. The file will be corrupt from the 0.5 MB mark onwards.

Flushing the ofstream between the writes, writing smaller blocks all make the
problem go away.


Built on OS X 10.8.5 and 10.9 with g++ 4.0.1, 4.2.1 and apple clang 5.0 and 5.1
using libstdc++ (6.0.9).

Tested on OS X 10.9, 10.10 (host) and Windows 7 and 8 (file server).

Version information:
$ g++-4.0 -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc_40/gcc_40-5494~315/src/configure
--disable-checking -enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
--with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --with-arch=apple --with-tune=generic
--host=i686-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5494)

$ g++-4.2 -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking
--enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

$ clang++ -v
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

$ clang++ -v
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix


Command-line to compile:
g++: g++ ./minimum-repro.cpp -o ./minimum-repro
clang: clang++ ./minimum-repro.cpp -stdlib=libstdc++ -o ./minimum-repro


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/65663] libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption
  2015-04-02 16:07 [Bug libstdc++/65663] New: libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption kkananen at gmail dot com
@ 2015-04-02 16:10 ` kkananen at gmail dot com
  2015-04-02 20:53 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: kkananen at gmail dot com @ 2015-04-02 16:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65663

--- Comment #1 from Kaarlo Kananen <kkananen at gmail dot com> ---
Created attachment 35217
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35217&action=edit
Original minimal reproduction .cpp

Full minimal reproduction source .cpp


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/65663] libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption
  2015-04-02 16:07 [Bug libstdc++/65663] New: libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption kkananen at gmail dot com
  2015-04-02 16:10 ` [Bug libstdc++/65663] " kkananen at gmail dot com
@ 2015-04-02 20:53 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-02 20:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65663

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-04-02
            Version|unknown                     |4.2.1
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Kaarlo Kananen from comment #0)
> Built on OS X 10.8.5 and 10.9 with g++ 4.0.1, 4.2.1 and apple clang 5.0 and
> 5.1 using libstdc++ (6.0.9).

Your version of libstdc++ is *ancient* (at least 7 years old) and not supported
or maintained.

Please either report it to Apple, who provided you with the ancient library, or
try with a newer version of libstdc++.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-02 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02 16:07 [Bug libstdc++/65663] New: libstdc++: writing mixed-size blocks through an std::ofstream to a SMB 2.1 share produces file corruption kkananen at gmail dot com
2015-04-02 16:10 ` [Bug libstdc++/65663] " kkananen at gmail dot com
2015-04-02 20:53 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).