This is a regression post 3.4.6. gcc-4.1.x, gcc-4.2.x, gcc-4.3.x all have it.
ie: // $ c++ -O -D_GLIBCXX_FULLY_DYNAMIC_STRING str.cc -o str #include <string> int main() { std::string abc; return 0; } gives: *** glibc detected *** ./a.out: free(): invalid pointer: 0xb7f3c678 *** ======= Backtrace: ========= /lib/libc.so.6[0x4a92f9ad] /lib/libc.so.6(cfree+0x90)[0x4a933000] /mnt/share/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6(_ZdlPv+0x21)[0xb7f0c2e1] /mnt/share/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x1d)[0xb7eea51d] ./a.out(__gxx_personality_v0+0x18d)[0x80486d9] /lib/libc.so.6(__libc_start_main+0xdc)[0x4a8dedec] ./a.out(__gxx_personality_v0+0x65)[0x80485b1] ======= Memory map: ======== 08048000-08049000 r-xp 00000000 fd:00 59605146 /home/bkoz/a.out 08049000-0804a000 rw-p 00000000 fd:00 59605146 /home/bkoz/a.out 0804a000-0806b000 rw-p 0804a000 00:00 0 [heap] 4a8ac000-4a8c5000 r-xp 00000000 fd:00 33917325 /lib/ld-2.5.so 4a8c5000-4a8c6000 r--p 00018000 fd:00 33917325 /lib/ld-2.5.so 4a8c6000-4a8c7000 rw-p 00019000 fd:00 33917325 /lib/ld-2.5.so 4a8c9000-4aa02000 r-xp 00000000 fd:00 33917354 /lib/libc-2.5.so 4aa02000-4aa04000 r--p 00139000 fd:00 33917354 /lib/libc-2.5.so 4aa04000-4aa05000 rw-p 0013b000 fd:00 33917354 /lib/libc-2.5.so 4aa05000-4aa08000 rw-p 4aa05000 00:00 0 4aa0a000-4aa2f000 r-xp 00000000 fd:00 33917357 /lib/libm-2.5.so 4aa2f000-4aa30000 r--p 00024000 fd:00 33917357 /lib/libm-2.5.so 4aa30000-4aa31000 rw-p 00025000 fd:00 33917357 /lib/libm-2.5.so b7e38000-b7e3a000 rw-p b7e38000 00:00 0 b7e3a000-b7e44000 r-xp 00000000 fd:00 51258449 /mnt/share/bld/gcc/gcc/libgcc_s.so.1 b7e44000-b7e45000 rw-p 00009000 fd:00 51258449 /mnt/share/bld/gcc/gcc/libgcc_s.so.1 b7e5d000-b7f36000 r-xp 00000000 fd:00 5210259 /mnt/share/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.9 b7f36000-b7f3a000 r--p 000d9000 fd:00 5210259 /mnt/share/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.9 b7f3a000-b7f3b000 rw-p 000dd000 fd:00 5210259 /mnt/share/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.9 b7f3b000-b7f42000 rw-p b7f3b000 00:00 0 b7f42000-b7f43000 r-xp b7f42000 00:00 0 [vdso] bfc74000-bfc8a000 rw-p bfc74000 00:00 0 [stack] Abort Fixing this is relatively easy, just forward-porting the changes to std::string::_Rep::_M_destroy that were taken out. See attached patch. -- Summary: empty std::string w/ _GLIBCXX_FULLY_DYNAMIC_STRING faults Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bkoz at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32284