| Contents |
|---|
This is the problem area:
std::basic_filebuf<char, std::char_traits<char> >::xsputn(char const*, long) - _ZNSt13basic_filebufIcSt11char_traitsIcEE6xsputnEPKcl(?)
std::basic_filebuf<char, std::char_traits<char> >::overflow(int) - _ZNSt13basic_filebufIcSt11char_traitsIcEE8overflowEi(?)
-> ? (0xffffffff) {0.005ms}
-> ? (0) {0.018ms}
As a result of this, cc1 fails to write the generated assembly into the output file. Unit test: tests/src/fstream.cpp
Problem source:
$ tools/sizeof.sh fstream 'std::filebuf::__state_type' sizeof(std::filebuf::__state_type)=8 $ ssh osx ./sizeof.sh fstream 'std::filebuf::__state_type' sizeof(std::filebuf::__state_type)=128 $ tools/sizeof.sh fstream 'std::__c_lock' sizeof(std::__c_lock)=40 $ ssh osx ./sizeof.sh fstream 'std::__c_lock' sizeof(std::__c_lock)=64 $ ssh osx ./sizeof.sh fstream 'std::ofstream' sizeof(std::ofstream)=896 $ tools/sizeof.sh fstream 'std::ofstream' sizeof(std::ofstream)=512
WORKAROUND
Problematic line in fstream.tcc:
const bool __testout = _M_mode & ios_base::out;
evaluates to false. FIXED.
Breakpoint 1, 0x0000003f8b8971c0 in std::ostream::write(char const*, long) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libstdc++.so.6
(gdb) bt
#0 0x0000003f8b8971c0 in std::ostream::write(char const*, long) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libstdc++.so.6
#1 0x00000001408be8eb in ?? ()
#2 0x0000000000000000 in ?? ()
(gdb) p (char*) $rdi
$1 = 0x1099450 "\030\370\062"
(gdb) p $rsi
$2 = 17451872
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fea3fa in std::basic_filebuf<char, std::char_traits<char> >::overflow (this=0x1099458, __c=9) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/fstream.tcc:466
466 *this->pptr() = traits_type::to_char_type(__c);
(gdb) bt
#0 0x00007ffff7fea3fa in std::basic_filebuf<char, std::char_traits<char> >::overflow (this=0x1099458, __c=9) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/fstream.tcc:466
#1 0x0000003f8b8a0745 in std::basic_streambuf<char, std::char_traits<char> >::xsputn(char const*, long) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libstdc++.so.6
#2 0x00007ffff7feb59a in std::basic_filebuf<char, std::char_traits<char> >::xsputn (this=0x1099458,
__s=0x10a4b60 "\t.section\t__TEXT,__text,regular,pure_instructions\n\t.globl\t_main\n\t.align\t4, 0x90\n_main:\n\tpushl\t%ebp\n\tmovl\t%esp, %ebp\n\tsubl\t$24, %esp\n\tcall\tL1$pb\nL1$pb:\n\tpopl\t%eax\n\tleal\tL_.str-L1$pb(%eax), %eax\n\tmovl\t%"..., __n=441) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/fstream.tcc:676
#3 0x0000003f8b897208 in std::ostream::write(char const*, long) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/libstdc++.so.6
#4 0x00000001408be8eb in ?? ()
#5 0x0000000000000000 in ?? ()
pthread_cond_wait() is called endlessly. Probably needs to be properly wrapped. FIXED.
Examine always_delete() and failure_delete() in gcc.