public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "andrey.vihrov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-64504-4@http.gcc.gnu.org/bugzilla/> (raw)

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 <iostream>
#include <string>

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)


             reply	other threads:[~2015-01-05 19:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05 19:46 andrey.vihrov at gmail dot com [this message]
2015-01-06 11:18 ` [Bug libstdc++/64504] " redi at gcc dot gnu.org
2015-01-06 14:08 ` andrey.vihrov at gmail dot com
2015-01-25 18:35 ` andrey.vihrov at gmail dot com
2015-01-26 10:56 ` rguenth at gcc dot gnu.org
2015-01-26 11:06 ` redi at gcc dot gnu.org
2015-06-09 15:12 ` andrey.vihrov at gmail dot com
2015-06-09 16:56 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64504-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).