[cfe-dev] fstream file I/O crash when accessing libstdc++-6 in clang compiled program

Kim soldoutseashell at gmail.com
Mon Sep 9 09:57:39 PDT 2013


Hey all,

Here's my simple program to demonstrate the issue. This is being 
compiled using clang with the mingw headers in windows.

#include <stdio.h>
#include <fstream>

     int main( void )
     {
         printf("Starting\n");

         std::ofstream ofs("whatever.txt");
         printf("Stream open\n");
         ofs << "testing\n";
         ofs.close();
         printf("Stream closed\n");

         return 0;
     }

C:\MinGW\bin>gdb script.exe
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from C:\MinGW\bin\script.exe...done.
(gdb)

(gdb) run
run

Starting program: C:\MinGW\bin\script.exe
[New Thread 9504.0x22a0]
[New Thread 9504.0x2674]
Starting
Stream open

Program received signal SIGSEGV, Segmentation fault.
0x6fc87a63 in libstdc++-6!_ZNSo6sentryC1ERSo ()
    from C:\MinGW\bin\libstdc++-6.dll
(gdb)

The result is the same compiling the program with clang built using 
visual studio or mingw. Of course, the program runs fine built with 
mingw g++.





More information about the cfe-dev mailing list