Opened 12 years ago
Last modified 8 years ago
#35070 assigned defect
gcc47: _GLIBCXX_DEBUG and empty ostringstream
Reported by: | akimd (Akim Demaille) | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.1.1 |
Keywords: | Cc: | rob.patro@… | |
Port: | gcc47 |
Description
Hi,
The following program fails on Mac OS X with both 4.7 and 4.8.
$ uname -a Darwin padam.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64 $ g++-mp-4.7 --version g++-mp-4.7 (MacPorts gcc47 4.7.1_0) 4.7.1 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-4.8 --version g++-mp-4.8 (MacPorts gcc48 4.8-20120701_0) 4.8.0 20120701 (experimental) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat simpleaut.cc # define _GLIBCXX_DEBUG 1 # include <sstream> int main() { std::ostringstream s; s.str(); } $ g++-mp-4.7 tests/unit/simpleaut.cc Using built-in specs. COLLECT_GCC=g++-mp-4.7 COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.1/lto-wrapper Target: x86_64-apple-darwin11 Configured with: ../gcc-4.7.1/configure --prefix=/opt/local --build=x86_64-apple-darwin11 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc47 4.7.1_0' Thread model: posix gcc version 4.7.1 (MacPorts gcc47 4.7.1_0) COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.7.4' '-v' '-shared-libgcc' '-mtune=core2' /opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.1/cc1plus -quiet -v -D__DYNAMIC__ foo.cc -fPIC -quiet -dumpbase foo.cc -mmacosx-version-min=10.7.4 -mtune=core2 -auxbase foo -version -o /var/folders/vc/vkjp1hhs5dgg8blcpzm6t59c0000gp/T//ccDjHKgh.s GNU C++ (MacPorts gcc47 4.7.1_0) version 4.7.1 (x86_64-apple-darwin11) compiled by GNU C version 4.7.1, GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/../../../../../x86_64-apple-darwin11/include" ignoring duplicate directory "/opt/local/include" as it is a non-system directory that duplicates a system directory #include "..." search starts here: #include <...> search starts here: /opt/local/include/gcc47/c++/ /opt/local/include/gcc47/c++//x86_64-apple-darwin11 /opt/local/include/gcc47/c++//backward /opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/include /opt/local/include /opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/include-fixed /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. GNU C++ (MacPorts gcc47 4.7.1_0) version 4.7.1 (x86_64-apple-darwin11) compiled by GNU C version 4.7.1, GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 09950ee4f031f09244f876c6af55ed8f COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.7.4' '-v' '-shared-libgcc' '-mtune=core2' /opt/local/bin/as -v -arch x86_64 -force_cpusubtype_ALL -o /var/folders/vc/vkjp1hhs5dgg8blcpzm6t59c0000gp/T//cc5KozFj.o /var/folders/vc/vkjp1hhs5dgg8blcpzm6t59c0000gp/T//ccDjHKgh.s Apple Inc version cctools-822, GNU assembler version 1.38 COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.1/:/opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.1/:/opt/local/libexec/gcc/x86_64-apple-darwin11/:/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/:/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/ LIBRARY_PATH=/opt/local/lib/:/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/:/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/../../../:/usr/lib/ COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.7.4' '-v' '-shared-libgcc' '-mtune=core2' /opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.7.4 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/opt/local/lib -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1 -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/../../.. /var/folders/vc/vkjp1hhs5dgg8blcpzm6t59c0000gp/T//cc5KozFj.o -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v collect2 version 4.7.1 /opt/local/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.7.4 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/opt/local/lib -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1 -L/opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1/../../.. /var/folders/vc/vkjp1hhs5dgg8blcpzm6t59c0000gp/T//cc5KozFj.o -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v @(#)PROGRAM:ld PROJECT:ld64-128.2 Library search paths: /opt/local/lib /opt/local/lib/gcc47/gcc/x86_64-apple-darwin11/4.7.1 /opt/local/lib/gcc47 /usr/lib /usr/local/lib Framework search paths: /Library/Frameworks/ /System/Library/Frameworks/ $ ./a.out a.out(28056) malloc: *** error for object 0x10a5f2340: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug zsh: abort ./a.out (gdb) bt #0 0x00007fff89bf582a in __kill () #1 0x00007fff89833a9c in abort () #2 0x00007fff8989284c in free () #3 0x0000000100000b86 in __gnu_cxx::new_allocator<char>::deallocate (this=0x7fff5fbff847, __p=0x1000d0340 "") at ext/new_allocator.h:102 #4 0x0000000100000b58 in std::string::_Rep::_M_destroy (this=0x1000d0340, __a=@0x7fff5fbff89f) at bits/basic_string.tcc:451 #5 0x0000000100000ae6 in std::string::_Rep::_M_dispose (this=0x1000d0340, __a=@0x7fff5fbff89f) at bits/basic_string.h:251 #6 0x00000001000009fd in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x7fff5fbffa20) at bits/basic_string.h:541 #7 0x0000000100000968 in main () at tests/unit/simpleaut.cc:7
Please, see the (wrong) bug report I made to the GCC team, where they emit ideas about the possible problem:
Change History (10)
comment:1 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | mww@… removed |
---|---|
Owner: | changed from macports-tickets@… to mww@… |
Summary: | _GLIBCXX_DEBUG and empty ostringstream → gcc47: _GLIBCXX_DEBUG and empty ostringstream |
comment:2 Changed 12 years ago by mww@…
comment:3 Changed 12 years ago by akimd (Akim Demaille)
Well, what is the best course of action from now on? I suggest putting you in CC of the ticket at gcc.gnu.org, and interacting with them there. WDYT?
comment:4 Changed 12 years ago by akimd (Akim Demaille)
I would like a clarification on
compiling gcc 4.7 with --enable-fully-dynamic-string fails on 10.7
you do mean that 4.7 cannot be compiled on 10.7 with --enable-fully-dynamic-string right? Not that my test case fails also with --enable-fully-dynamic-string.
comment:5 Changed 12 years ago by mww@…
yes, adding "--enable-fully-dynamic-string" to the configure.args of Portfile of gcc47 makes it FAIL to compile on OS X 10.7. Did you mean that your test also fails or that it does not?
comment:6 Changed 12 years ago by akimd (Akim Demaille)
Did you mean that your test also fails or that it does not?
Nope, I just meant to be sure that I could report to the GCC team that there is a problem with building GCC with --enable-fully-dynamic-string.
Do you have logs somewhere? Is there something to report to them about this failure?
comment:7 Changed 12 years ago by akimd (Akim Demaille)
Well, it seems that we do have two different issues.
One is that GCC fails to build with --enable-fully-dynamic-string. As far as the GCC team knows, GCC builds fine on this architecture with --enable-fully-dynamic-string, so it must be something specific to the MacPorts. If there is really something about GCC per se, then the GCC team would like a specific ticket (all this is stated here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53838#c5).
The other problem is the one that I reported. With or without --enable-fully-dynamic-string, the test case I sent is expected to run properly, which is not the case on MacPorts. What would you like to know to get this bug fixed?
Thanks!
comment:8 Changed 12 years ago by rob.patro@…
Cc: | rob.patro@… added |
---|
This bug still exists and, among other things, causes boost to fail in a number of cases.
Cc Me!
comment:9 Changed 11 years ago by barto@…
Adding that g++-mp-4.8 also has this problem.
And it affects std::string as well.
ui3(2112) malloc: * error for object 0x100084f00: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug
Breakpoint 2, 0x00007fff97855588 in malloc_error_break ()
(gdb) where #1 0x00007fff97856942 in free () #2 0x00000001063c1f3c in std::string::reserve () #3 0x0000010701620000 in ?? ()
Turning off the _GLIBCXX_DEBUG 'fixes' the issue. This is happening in my global constructors. So something in the MacPort version of the libstdc++ library is not working when turning on the debug flag for array bounds checking.
comment:10 Changed 8 years ago by kurthindenburg (Kurt Hindenburg)
Owner: | changed from mww@… to macports-tickets@… |
---|---|
Status: | new → assigned |
compiling gcc 4.7 with --enable-fully-dynamic-string fails on 10.7; also when trying your example the resuling binary is linked to our gcc's C++-lib