Bug 51722 - [4.7 Regression] Options "-g3" or "-ggdb3" or "-g3 -gdwarf-2" and other "-g..level3" - internal compiler error
Summary: [4.7 Regression] Options "-g3" or "-ggdb3" or "-g3 -gdwarf-2" and other "-g.....
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-31 17:30 UTC by Yuriy Lalym
Modified: 2012-01-03 13:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.2
Known to fail:
Last reconfirmed: 2012-01-01 00:00:00


Attachments
For example in Comment 4 (136.85 KB, text/plain)
2012-01-02 18:57 UTC, Yuriy Lalym
Details
new example (1.96 KB, text/plain)
2012-01-03 06:05 UTC, Yuriy Lalym
Details
And pch.ii (8.48 KB, application/octet-stream)
2012-01-03 06:08 UTC, Yuriy Lalym
Details
only main with empty pch (1.96 KB, text/plain)
2012-01-03 06:17 UTC, Yuriy Lalym
Details
And pch.ii (1.96 KB, text/plain)
2012-01-03 06:17 UTC, Yuriy Lalym
Details
gcc47-pr51722.patch (1.41 KB, patch)
2012-01-03 09:54 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuriy Lalym 2011-12-31 17:30:45 UTC
cd src/ && /usr/bin/qmake /data/yura/eclipse1/workspace/gxbook-src-0.0.1/src/src.pro CONFIG+=debug QMAKE_CC=gcc-4.7 QMAKE_CXX=g++-4.7 QMAKE_LINK=g++-4.7 QMAKE_CFLAGS_DEBUG=-g3\ -gdwarf-4\ -fvar-tracking-assignments QMAKE_CXXFLAGS_DEBUG=-g3\ -gdwarf-4\ -fvar-tracking-assignments -o Makefile
cd src/ && /usr/bin/gmake -f Makefile 
gmake[1]: Entering directory `/data/yura/eclipse1/workspace/gxbook-src-0.0.1/build/debug/src'
g++-4.7 -m64 -pipe -std=c++0x -g3 -gdwarf-4 -fvar-tracking-assignments -D_REENTRANT -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I../../../src -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I../../../src -I. -x c++-header -c ../../../src/headers.h -o gxbook.gch/c++
g++-4.7 -c -include gxbook -m64 -pipe -std=c++0x -g3 -gdwarf-4 -fvar-tracking-assignments -D_REENTRANT -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I../../../src -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I../../../src -I. -o main.o ../../../src/main.cpp
*** glibc detected *** /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus: free(): invalid pointer: 0x000000100004e420 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x74c06)[0x7f1af7d75c06]
/usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus[0x5effd4]
/usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus[0x79a977]
/lib64/libc.so.6(__libc_start_main+0xed)[0x7f1af7d2223d]
/usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus[0x41a051]
======= Memory map: ========
00400000-00fd8000 r-xp 00000000 08:02 103794313 /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus
011d7000-011d8000 r--p 00bd7000 08:02 103794313 /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus
011d8000-011e3000 rw-p 00bd8000 08:02 103794313 /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus
011e3000-014b6000 rw-p 00000000 00:00 0                                  [heap]
1000000000-1002bf5000 rw-p 00085000 08:11 572044 /data/yura/eclipse1/workspace/gxbook-src-0.0.1/build/debug/src/gxbook.gch/c++
7f1af6be1000-7f1af77e1000 rw-p 00000000 00:00 0 
7f1af77e1000-7f1af77f6000 r-xp 00000000 08:02 37392436 /lib64/libgcc_s.so.1
7f1af77f6000-7f1af79f5000 ---p 00015000 08:02 37392436 /lib64/libgcc_s.so.1
7f1af79f5000-7f1af79f6000 r--p 00014000 08:02 37392436 /lib64/libgcc_s.so.1
7f1af79f6000-7f1af79f7000 rw-p 00015000 08:02 37392436 /lib64/libgcc_s.so.1
7f1af79f7000-7f1af7ae3000 r-xp 00000000 08:02 181198   /usr/lib64/libstdc++.so.6.0.16
7f1af7ae3000-7f1af7ce2000 ---p 000ec000 08:02 181198   /usr/lib64/libstdc++.so.6.0.16
7f1af7ce2000-7f1af7cea000 r--p 000eb000 08:02 181198   /usr/lib64/libstdc++.so.6.0.16
7f1af7cea000-7f1af7cec000 rw-p 000f3000 08:02 181198   /usr/lib64/libstdc++.so.6.0.16
7f1af7cec000-7f1af7d01000 rw-p 00000000 00:00 0 
7f1af7d01000-7f1af7e86000 r-xp 00000000 08:02 33554966 /lib64/libc-2.14.1.so
7f1af7e86000-7f1af8086000 ---p 00185000 08:02 33554966 /lib64/libc-2.14.1.so
7f1af8086000-7f1af808a000 r--p 00185000 08:02 33554966 /lib64/libc-2.14.1.so
7f1af808a000-7f1af808b000 rw-p 00189000 08:02 33554966 /lib64/libc-2.14.1.so
7f1af808b000-7f1af8090000 rw-p 00000000 00:00 0 
7f1af8090000-7f1af80e6000 r-xp 00000000 08:02 33554935 /lib64/libm-2.14.1.so
7f1af80e6000-7f1af82e5000 ---p 00056000 08:02 33554935 /lib64/libm-2.14.1.so
7f1af82e5000-7f1af82e6000 r--p 00055000 08:02 33554935 /lib64/libm-2.14.1.so
7f1af82e6000-7f1af82e7000 rw-p 00056000 08:02 33554935 /lib64/libm-2.14.1.so
7f1af82e7000-7f1af835b000 r-xp 00000000 08:02 181227   /usr/lib64/libgmp.so.10.0.2
7f1af835b000-7f1af855a000 ---p 00074000 08:02 181227   /usr/lib64/libgmp.so.10.0.2
7f1af855a000-7f1af855b000 r--p 00073000 08:02 181227   /usr/lib64/libgmp.so.10.0.2
7f1af855b000-7f1af8564000 rw-p 00074000 08:02 181227   /usr/lib64/libgmp.so.10.0.2
7f1af8564000-7f1af85b9000 r-xp 00000000 08:02 5072     /usr/lib64/libmpfr.so.4.0.1
7f1af85b9000-7f1af87b8000 ---p 00055000 08:02 5072     /usr/lib64/libmpfr.so.4.0.1
7f1af87b8000-7f1af87ba000 r--p 00054000 08:02 5072     /usr/lib64/libmpfr.so.4.0.1
7f1af87ba000-7f1af87bb000 rw-p 00056000 08:02 5072     /usr/lib64/libmpfr.so.4.0.1
7f1af87bb000-7f1af87ce000 r-xp 00000000 08:02 5110     /usr/lib64/libmpc.so.2.0.0
7f1af87ce000-7f1af89cd000 ---p 00013000 08:02 5110     /usr/lib64/libmpc.so.2.0.0
7f1af89cd000-7f1af89ce000 r--p 00012000 08:02 5110     /usr/lib64/libmpc.so.2.0.0
7f1af89ce000-7f1af89cf000 rw-p 00013000 08:02 5110     /usr/lib64/libmpc.so.2.0.0
7f1af89cf000-7f1af89d2000 r-xp 00000000 08:02 5115     /usr/lib64/libgmpxx.so.4.2.2
7f1af89d2000-7f1af8bd2000 ---p 00003000 08:02 5115     /usr/lib64/libgmpxx.so.4.2.2
7f1af8bd2000-7f1af8bd3000 r--p 00003000 08:02 5115     /usr/lib64/libgmpxx.so.4.2.2
7f1af8bd3000-7f1af8bd4000 rw-p 00004000 08:02 5115     /usr/lib64/libgmpxx.so.4.2.2
7f1af8bd4000-7f1af8cc3000 r-xp 00000000 08:02 5062     /usr/lib64/libppl.so.9.0.0
7f1af8cc3000-7f1af8ec3000 ---p 000ef000 08:02 5062     /usr/lib64/libppl.so.9.0.0
7f1af8ec3000-7f1af8ec4000 r--p 000ef000 08:02 5062     /usr/lib64/libppl.so.9.0.0
7f1af8ec4000-7f1af8ec6000 rw-p 000f0000 08:02 5062     /usr/lib64/libppl.so.9.0.0
7f1af8ec6000-7f1af8ec7000 rw-p 00000000 00:00 0 
7f1af8ec7000-7f1af92bd000 r-xp 00000000 08:02 5008     /usr/lib64/libppl_c.so.4.0.0
7f1af92bd000-7f1af94bc000 ---p 003f6000 08:02 5008     /usr/lib64/libppl_c.so.4.0.0
7f1af94bc000-7f1af94bd000 r--p 003f5000 08:02 5008     /usr/lib64/libppl_c.so.4.0.0
7f1af94bd000-7f1af94c1000 rw-p 003f6000 08:02 5008     /usr/lib64/libppl_c.so.4.0.0
7f1af94c1000-7f1af94c2000 rw-p 00000000 00:00 0 
7f1af94c2000-7f1af94e1000 r-xp 00000000 08:02 5146     /usr/lib64/libcloog.so.0.0.0
7f1af94e1000-7f1af96e1000 ---p 0001f000 08:02 5146     /usr/lib64/libcloog.so.0.0.0
7f1af96e1000-7f1af96e2000 r--p 0001f000 08:02 5146     /usr/lib64/libcloog.so.0.0.0
7f1af96e2000-7f1af96e3000 rw-p 00020000 08:02 5146     /usr/lib64/libcloog.so.0.0.0
7f1af96e3000-7f1af96e5000 rw-p 00000000 00:00 0 
7f1af96e5000-7f1af9705000 r-xp 00000000 08:02 34486382 /lib64/ld-2.14.1.so
7f1af9873000-7f1af98de000 rw-p 00000000 00:00 0 
7f1af98de000-7f1af98e2000 rw-p 00000000 00:00 0 
7f1af98f2000-7f1af9905000 rw-p 00000000 00:00 0 
7f1af9905000-7f1af9906000 r--p 00020000 08:02 34486382 /lib64/ld-2.14.1.so
7f1af9906000-7f1af9907000 rw-p 00021000 08:02 34486382 /lib64/ld-2.14.1.so
7f1af9907000-7f1af9908000 rw-p 00000000 00:00 0 
7fffae539000-7fffae55b000 rw-p 00000000 00:00 0        [stack]
7fffae5ff000-7fffae600000 r-xp 00000000 00:00 0        [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
../../../src/main.cpp:29:1: internal compiler error: Aborted
Comment 1 Paolo Carlini 2012-01-01 11:10:45 UTC
Please provide all the required information, in particular the preprocessed .ii: http://gcc.gnu.org/bugs/#need
Comment 2 Richard Biener 2012-01-02 10:15:57 UTC
Try disabling PCH, too.  If PCH is required to reproduce the bug also
include all preprocessed headers to build the PCH.
Comment 3 Yuriy Lalym 2012-01-02 15:06:30 UTC
Without PCH errors aren't present.
> all preprocessed headers to build the PCH

#include <stdio.h>

It is enough one header for error origin.
Comment 4 Yuriy Lalym 2012-01-02 15:16:03 UTC
main.cpp
-----------------------------------
#include <QtCore/QCoreApplication>

int main(int argc, char *argv[])
{
  QCoreApplication a(argc, argv);

  return a.exec();
}

-----------------------------------
pch.h
-----------------------------------
#include <stdio.h>

g++-4.7 -m64 -pipe -g3 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include -I. -x c++-header -c pch.h -o untitled5.gch/c++
g++-4.7 -c -include untitled5 -m64 -pipe -g3 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include -I. -o main.o main.cpp
*** glibc detected *** /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus: double free or corruption (out): 0x000000100000c180 ***
Comment 5 Yuriy Lalym 2012-01-02 18:50:23 UTC
gcc-4.7 -v
Using built-in specs.
COLLECT_GCC=gcc-4.7
COLLECT_LTO_WRAPPER=/usr/local/lib/gcc/x86_64-suse-linux/4.7.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr/local --libdir=/usr/local/lib64 --libexecdir=/usr/local/lib64 --enable-languages=c,c++ --enable-checking=release --with-gxx-include-dir=/usr/local/include/c++/4.7 --enable-ssp --disable-libssp --disable-plugin --with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib64 --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.7 --enable-linux-futex --without-system-libunwind --with-tune=core2 --build=x86_64-suse-linux : (reconfigured) ../configure --prefix=/usr/local --libdir=/usr/local/lib64 --libexecdir=/usr/local/lib64 --enable-languages=c,c++ --enable-checking=release --with-gxx-include-dir=/usr/local/include/c++/4.7 --enable-ssp --disable-libssp --disable-plugin --with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib64 --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.7 --enable-linux-futex --without-system-libunwind --with-tune=core2 --build=x86_64-suse-linux
Thread model: posix
gcc version 4.7.0 20120102 (experimental) (SUSE Linux)
Comment 6 Yuriy Lalym 2012-01-02 18:57:40 UTC
Created attachment 26220 [details]
For example in Comment 4
Comment 7 Hans-Peter Nilsson 2012-01-03 04:39:05 UTC
(In reply to comment #6)
> Created attachment 26220 [details]
> For example in Comment 4

Sorry, that file contains a reference to precompiled headers:
#pragma GCC pch_preprocess "./untitled5.gch/c++"

so we'd need "all preprocessed headers to build the PCH" (I'm not sure how to find those from the above line).  On a somewhat closer look, the precompiled header is found within the Qt-headers, so maybe you just need to rebuild *that* without precompiled headers to create a debuggable context we can use.
Comment 8 Yuriy Lalym 2012-01-03 06:05:23 UTC
Created attachment 26224 [details]
new example

--------------------
main.cpp
--------------------
int main()
{
  return 0;
}

--------------------
pch.h
--------------------
#include <stdio.h>

>>>>>> -g2
g++-4.7 -m64 -pipe -g2 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT   -x c++-header -c pch.h -o untitled5.gch/c++
g++-4.7 -c -include untitled5 -m64 -pipe -g2 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT   -o main.o main.cpp
g++-4.7 -m64 -o untitled5 main.o    -L/usr/lib64 -lpthread
good

>>>>>> -g3
g++-4.7 -m64 -pipe -g3 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT   -x c++-header -c pch.h -o untitled5.gch/c++
g++-4.7 -c -include untitled5 -m64 -pipe -g3 -gdwarf-4 -fvar-tracking-assignments -Wall -W -D_REENTRANT -o main.o main.cpp
*** glibc detected *** /usr/local/lib/gcc/x86_64-suse-linux/4.7.0/cc1plus: munmap_chunk(): invalid pointer: 0x000000100000ba20 ***
Comment 9 Yuriy Lalym 2012-01-03 06:08:14 UTC
Created attachment 26225 [details]
And pch.ii
Comment 10 Yuriy Lalym 2012-01-03 06:17:03 UTC
Created attachment 26226 [details]
only main with empty pch

--------------------
main.cpp
--------------------
int main()
{
  return 0;
}

--------------------
pch.h
--------------------
// Empty
Comment 11 Yuriy Lalym 2012-01-03 06:17:49 UTC
Created attachment 26227 [details]
And pch.ii
Comment 12 Richard Biener 2012-01-03 09:07:39 UTC
Confirmed with the recipie in comment #8 (using glibc 2.11.1 headers).  It's
enough to use -g3 vs. -g2, suspect Dodji's work here.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff61f4f58 in *__GI___libc_free (mem=0x10000030b0) at malloc.c:3736
3736    malloc.c: No such file or directory.
        in malloc.c
(gdb) up
#1  0x00000000009cf9c7 in output_macinfo ()
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:20940
20940           free (CONST_CAST (char *, ref->info));
(gdb) p *ref
$2 = {code = 5 '\005', lineno = 1, info = 0x10000030b0 "__STDC__ 1"}
Comment 13 Jakub Jelinek 2012-01-03 09:54:42 UTC
Created attachment 26230 [details]
gcc47-pr51722.patch

Untested fix.
Comment 14 Jakub Jelinek 2012-01-03 13:45:47 UTC
Author: jakub
Date: Tue Jan  3 13:45:41 2012
New Revision: 182845

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182845
Log:
	PR pch/51722
	* dwarf2out.c (dwarf2out_start_source_file, dwarf2out_define,
	dwarf2out_undef): Allocate e.info using ggc_strdup instead
	of xstrdup.
	(output_macinfo_op): Don't ggc_strdup fd->filename.
	(optimize_macinfo_range): Allocate grp_name using XALLOCAVEC,
	then ggc_strdup it.  Don't free inc->info or cur->info.
	(output_macinfo): Don't free ref->info or file->info.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
Comment 15 Jakub Jelinek 2012-01-03 13:47:48 UTC
Fixed.