From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27856 invoked by alias); 5 Jan 2015 19:46:18 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 27813 invoked by uid 48); 5 Jan 2015 19:46:12 -0000 From: "andrey.vihrov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64504] New: Invalid free() with _GLIBCXX_DEBUG and -fwhole-program Date: Mon, 05 Jan 2015 19:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andrey.vihrov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00267.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64504 Bug ID: 64504 Summary: Invalid free() with _GLIBCXX_DEBUG and -fwhole-program Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: andrey.vihrov at gmail dot com Created attachment 34383 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34383&action=edit Preprocessed source Compiling the following program: #define _GLIBCXX_DEBUG #include #include int main() { std::string s; std::cin >> s; } with "g++ -fwhole-program x.cpp" gives me *** Error in `./a.out': free(): invalid pointer: 0x00000000006017c0 *** ======= Backtrace: ========= /usr/lib/libc.so.6(+0x732ae)[0x7fb15966e2ae] /usr/lib/libc.so.6(+0x7872e)[0x7fb15967372e] /usr/lib/libc.so.6(+0x78eeb)[0x7fb159673eeb] /usr/lib/libstdc++.so.6(_ZNSs7reserveEm+0xa4)[0x7fb159f7d3e4] /usr/lib/libstdc++.so.6(_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_E+0x214)[0x7fb159f302f4] ./a.out[0x400b40] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fb15961b040] ./a.out[0x4009a9] This is on 64-bit Arch Linux with GCC 4.9.2. My understanding of -fwhole-program is that it can be used with one source file that includes standard library headers and links with the standard library. If this is wrong, then I'm sorry for filing a bogus bug report. I have searched for similar reports and found bug #53838. And indeed the sample program from that bug also crashes with the same message. However, my system has only one GCC and libstdc++, unlike in that case. gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc-multilib/src/gcc-4.9-20141224/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.9.2 20141224 (prerelease) (GCC)