Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 209253 - [4.1/4.2/ICE] gcc fails due to mangling symbols required by the -g flag.
Summary: [4.1/4.2/ICE] gcc fails due to mangling symbols required by the -g flag.
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://gcc.gnu.org/PR13740
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-07 14:29 UTC by Luis Fernando Schultz Xavier da Silveira
Modified: 2008-02-19 20:34 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
preprocessed source code (src.i++,151.05 KB, text/plain)
2008-02-07 16:31 UTC, Luis Fernando Schultz Xavier da Silveira
Details
ice.ii (ice.ii,754 bytes, text/plain)
2008-02-17 08:40 UTC, SpanKY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luis Fernando Schultz Xavier da Silveira 2008-02-07 14:29:22 UTC
I have written a project which causes gcc 4.1.2 to fail with an ICE due to mangling symbols required by the -g flag.

I have spent a whole day trying to reduce the test case, but did not succeed, so I am sending the whole project link instead.

My brother uses kubuntu, and the same version of gcc fails there even without the -g flag.

I did use some nasty code because I was trying to develop a metaprogramming library.

Apparently, the mistake came from the file language/keywords, in which the instanceof macro is defined.

The make process aborts when compiling the second source file, circle.c++, with an error indicating an ICE.

Reproducible: Always

Steps to Reproduce:
0. Download the project tarballs. You can visit my page (http://www.inf.ufsc.br/~schultz) or browse my dist directory (http://www.inf.ufsc.br/~schultz/c/).

1. Extract the tarballs.

2. Ignore the license files, they are a joke. =)

3. Check the requirements in the readme file.

4. Edit the make.conf file. In this step, put the -g option in the CFLAGS to see the bug and remove it to have a working app.

5. Compile the application. (make clean && make)

6. The bug arises then.
Actual Results:  
gcc outputs an ICE message in the second make step

Expected Results:  
compiled the whole app successfully

Portage 2.1.3.19 (default-linux/x86/2007.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.23-gentoo-r6 i686)
=================================================================
System uname: 2.6.23-gentoo-r6 i686 Intel(R) Pentium(R) M processor 1.50GHz
Timestamp of tree: Wed, 06 Feb 2008 20:30:04 +0000
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p17-r1
dev-lang/python:     2.4.4-r6
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.10-r5
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="x86"
CBUILD="i486-pc-linux-gnu"
CFLAGS="-march=pentium-m -O2 -pipe -fomit-frame-pointer"
CHOST="i486-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=pentium-m -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://www.las.ic.unicamp.br/pub/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac aalib acl acpi alsa amrnb amrwb arts artswrappersuid bash-completion berkdb bidi binary bitmap-fonts bl branding bzip2 cairo cdparanoia cjk cli cracklib crypt cscope cups d dbus dga directfb djvu dri dts dv dvd enca encode expat fbcon fftw flac fontconfig fortran gd gdbm geoip ggi gif glib gmp gnutls gpm graphviz gs gtk guile hal hddtemp hpn iconv idea idn ieee1394 imlib ipv6 isdnlog javascript joystick jpeg jpeg2k kde kdehiddenvisibility kerberos krb4 lame lapack latex lcms ldap libcaca libedit libsamplerate lzo mad md5sum midi mikmod mmap mmx mng motif mp2 mp3 mpeg mudflap musepack ncurses nemesi networking nls nptl nptlonly objc objc++ objc-gc ocaml offensive ogg openal openexr opengl openmp pam pch pcmcia pcre pdf perl plotutils png pppd python qt3 qt4 quicktime readline reflection rtc ruby sdl session slang sndfile speex spell spl sse sse2 ssl svg svga tcl tcpd tetex tga theora threads tiff tk truetype truetype-fonts type1-fonts unicode vidix vim-pager vim-syntax vim-with-x vorbis vorbis-psy win32codecs wmf x86 xanim xml xorg xpm xscreensaver xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse synaptics evdev joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="i810"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2008-02-07 15:35:05 UTC
Attach a sample code to reproduce and preprocessed source to this bug and reopen then; thanks.
Comment 2 Luis Fernando Schultz Xavier da Silveira 2008-02-07 16:31:34 UTC
Created attachment 142901 [details]
preprocessed source code

this is the source which gcc fails to compile with -g
Comment 3 Luis Fernando Schultz Xavier da Silveira 2008-02-07 16:34:21 UTC
I am sorry for not sending the source.

I forgot gcc puts the source in /tmp.

2^16 apologies.

Still, I failed to reduce the test case, and the source is about 6500 lines! Sorry for the inconvenience.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2008-02-07 16:41:40 UTC
Thanks. :)
Comment 5 Luis Fernando Schultz Xavier da Silveira 2008-02-16 01:03:28 UTC
Just to add something I have observed.

My brother uses kubuntu and gcc 4.1.2 fails there even without -g.

Does not know if that helps, so I am just saying it.
Comment 6 SpanKY gentoo-dev 2008-02-17 08:35:21 UTC
looks like the answer from upstream is "change your code"
Comment 7 SpanKY gentoo-dev 2008-02-17 08:40:02 UTC
Created attachment 143746 [details]
ice.ii

reduced for fun :p
Comment 8 Luis Fernando Schultz Xavier da Silveira 2008-02-19 00:39:11 UTC
Thank you very much for the short test case. I have sought that for long, but never managed to achieve it.

With that in hands, I can try to make the online judge I use to train for the ACM ICPC fail, for it is up to 40KB.

Now, I do not know what does "upstream" mean. However, I was expecting the "change your code" answer. I know there are loads of bugs gcc developers have to address. If I knew enough of compiler stuff, I would help myself, for gcc is the best piece of free software there is, in my opinion.

Nevertheless, such an answer should never be given. I know my code is ugly, obscure, horrible and that no developer will ever use it, most likely. However, gcc is a program that no matter the input file, should never cause a segmentation fault. Well, no program should ever cause a segmentation fault anyway. Therefore, from the formal point of view, gcc is an incorrect program. *All* bugs must be solved, and this is a bug.

I could understand if the answer was "you will have to wait, too many more important bugs in the 'queue'". But "change your code" is rather ugly. Changing the code hides the bug, but does not solve it. Systems like the online judge I have mentioned rely on the correctness of gcc for every possible input.

I will someday read the mangle.c source file line-by-line to figure out what happened if that is the final answer from the "upstream".

Thanks once more for that piece of code, SpanKY. You really helped me.
Comment 9 SpanKY gentoo-dev 2008-02-19 01:17:21 UTC
what it means is the upstream gcc project said they arent going to fix this.  Gentoo will follow what upstream says.  (yes i know it sort of sucks for you)

look at the URL provided in the bugzilla URL field for more information
Comment 10 Luis Fernando Schultz Xavier da Silveira 2008-02-19 20:34:38 UTC
Hmm, I have read that link and I am surprised gcc has that bug since version 3.0. My hopes of it being fixed until 4.2/4.3 went down the sink. =(

I can live without that feature, really. I seldomly use gdb anyway, so the mangling symbols do not make themselves important. However, as I have reported, kubuntu 7.10's gcc 4.1.2 fails even without -g, so I am afraid to distribute my code in that state.

I followed the thread and checked out that is a hard bug to fix, but as someone commented there, it is a pity a GNU extension does not work in the GNU compiler.

Unfortunately, typeof is just something you cannot make yourself within the ANSI standard, otherwise I would write it myself. And it is a promising candidate for inclusion in the next C++ standard.

I think I will change my code in some spots for it to compile ok with gcc.

Thanks for the help.