I have a very simple objective-c file, "Test.m": #import <objc/Object.h> @interface Test: Object { int i; } @end Test *global_var; @implementation Test +initialize { global_var = [Test new]; } @end When I run "gcc -v -fobjc-gc Test.m", the compiler segfaults, with output to stderr as follows: Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.2.3/work/gcc-4.2.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --enable-objc-gc --enable-languages=c,c++,objc,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 4.2.3 (Gentoo 4.2.3 p1.0) /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.3/cc1obj -quiet -v Test.m -quiet -dumpbase Test.m -mtune=generic -auxbase Test -version -fobjc-gc -o /tmp/ccbyb4fy.s ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.3/include /usr/include End of search list. GNU Objective-C version 4.2.3 (Gentoo 4.2.3 p1.0) (x86_64-pc-linux-gnu) compiled by GNU C version 4.2.3 (Gentoo 4.2.3 p1.0). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 94f28a5fd1e0610428671fade634b516 Test.m: In function '+[Test initialize]': Test.m:11: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.gentoo.org/> for instructions. Preprocessed source stored into /tmp/ccIGTpYR.out file, please attach this to your bugreport. Reproducible: Always Steps to Reproduce: emerge --info: Portage 2.1.5_rc4 (default-linux/amd64/2006.1/desktop, gcc-4.2.3, glibc-2.7-r2, 2.6.21-suspend2-r7 x86_64) ================================================================= System uname: 2.6.21-suspend2-r7 x86_64 Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz Timestamp of tree: Sat, 19 Apr 2008 13:34:01 +0000 ccache version 2.4 [enabled] app-shells/bash: 3.2_p33 dev-java/java-config: 1.3.7, 2.1.5 dev-lang/python: 2.5.2-r1 dev-util/ccache: 2.4-r7 sys-apps/baselayout: 2.0.0 sys-apps/openrc: 0.2.2 sys-apps/sandbox: 1.2.18.1-r2 sys-devel/autoconf: 2.13, 2.62 sys-devel/automake: 1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1 sys-devel/binutils: 2.18-r1 sys-devel/gcc-config: 1.4.0-r4 sys-devel/libtool: 1.5.26 virtual/os-headers: 2.6.24 ABI="amd64" ACCEPT_KEYWORDS="amd64 ~amd64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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" ARCH="amd64" ASFLAGS_x86="--32" AUTOCLEAN="yes" CACA_FONT="5x7" CACA_GEOMETRY="256x114" CBUILD="x86_64-pc-linux-gnu" CCACHE_DIR="/var/tmp/ccache/" CCACHE_SIZE="2G" CDEFINE_amd64="__x86_64__" CDEFINE_x86="__i386__" CFLAGS="-O3 -fomit-frame-pointer -march=nocona -pipe" CFLAGS_x86="-m32 -L/emul/linux/x86/lib -L/emul/linux/x86/usr/lib" CHOST="x86_64-pc-linux-gnu" CHOST_amd64="x86_64-pc-linux-gnu" CHOST_x86="i686-pc-linux-gnu" CLASSPATH="." CLEAN_DELAY="5" COLUMNS="101" CONFIG_PROTECT="/etc" CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d" CVS_RSH="ssh" CXXFLAGS="-O3 -fomit-frame-pointer -march=nocona -pipe" DEFAULT_ABI="amd64" DISPLAY=":0" DISTDIR="/usr/portage/distfiles" EDITOR="/bin/nano" ELIBC="glibc" EMACS="23.0.50.1 (term:0.96)" EMERGE_WARNING_DELAY="10" FEATURES="ccache distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch" FETCHCOMMAND="/usr/bin/wget -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}"" GCC_SPECS="" GDK_USE_XFT="1" GENERATION="2" GENTOO_MIRRORS="ftp://mirrors.64hosting.com/pub/mirrors/gentoo/ http://140.127.177.17/pub/Linux/Gento ftp://140.127.77.15/pub/Linux/Gentoo" GIT_EDITOR="emacsclient" GPG_AGENT_INFO="/tmp/gpg-5JNpnQ/S.gpg-agent:4765:1" HGEDITOR="emacsclient" HOME="/home/daedalus" HUSHLOGIN="FALSE" INFOPATH="/usr/share/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.18/info:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.3/info:/usr/share/info/emacs-23" INPUT_DEVICES="keyboard mouse" INSIDE_EMACS="23.0.50.1,term:0.96" JAVAC="/etc/java-config-2/current-system-vm/bin/javac" JAVA_HOME="/etc/java-config-2/current-system-vm" JDK_HOME="/etc/java-config-2/current-system-vm" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LDFLAGS="" LDFLAGS_x86="-m elf_i386 -L/emul/linux/x86/lib -L/emul/linux/x86/usr/lib" LESS="-R -M --shift 5" LESSOPEN="|lesspipe.sh %s" LIBDIR_amd64="lib64" LIBDIR_x86="lib32" LIBGL_DRIVERS_PATH="/usr/lib64/dri:/usr/lib32/dri" LINES="68" LOGNAME="root" LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" MAIL="/var/mail/daedalus" MAKEOPTS="-j3" MANPATH="/etc/java-config-2/current-system-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.18/man:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.3/man:/opt/blackdown-jdk-1.4.2.03/man:/etc/java-config/system-vm/man/" MC_MODE="" MULTILIB_ABIS="amd64 x86" MULTILIB_STRICT_DENY="64-bit.*shared object" MULTILIB_STRICT_DIRS="/lib /usr/lib /usr/kde/*/lib /usr/qt/*/lib /usr/X11R6/lib" MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage)" NOCOLOR="true" OLDPWD="/home/daedalus/code/c/guts" OPENGL_PROFILE="xorg-x11" PAGER="/usr/bin/less" PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin" PKGDIR="/usr/portage/packages" PORTAGE_ARCHLIST="ppc s390 amd64 x86 ppc64 x86-fbsd m68k arm sparc sh mips ia64 alpha hppa sparc-fbsd" PORTAGE_BINHOST_CHUNKSIZE="3000" PORTAGE_BIN_PATH="/usr/lib64/portage/bin" PORTAGE_CONFIGROOT="/" PORTAGE_DEBUG="0" PORTAGE_DEPCACHEDIR="/var/cache/edb/dep" PORTAGE_ELOG_CLASSES="warn error log" PORTAGE_ELOG_MAILFROM="portage@localhost" PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}" PORTAGE_ELOG_MAILURI="root" PORTAGE_ELOG_SYSTEM="save" PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5" PORTAGE_FETCH_RESUME_MIN_SIZE="350K" PORTAGE_GID="250" PORTAGE_INST_GID="0" PORTAGE_INST_UID="0" PORTAGE_PYM_PATH="/usr/lib64/portage/pym" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_RSYNC_RETRIES="3" PORTAGE_TMPDIR="/var/tmp" PORTAGE_WORKDIR_MODE="0700" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/portage/local/layman/d" PORT_LOGDIR="/var/log/portage/" PWD="/home/daedalus/code/objc" PYTHONPATH="/usr/lib64/portage/pym" RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}"" ROOT="/" ROOTPATH="/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.3:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin" RPMDIR="/usr/portage/rpm" RUBYOPT="-rauto_gem" SBCL_HOME="/usr/lib64/sbcl" SBCL_SOURCE_ROOT="/usr/lib64/sbcl/src" SHELL="/bin/zsh" SHLVL="4" SSH_AGENT_PID="4739" SSH_AUTH_SOCK="/tmp/ssh-hmvSmy4738/agent.4738" STAGE1_USE="nptl nptlonly unicode" SUDO_COMMAND="/usr/bin/emerge -v --info" SUDO_GID="1000" SUDO_UID="1000" SUDO_USER="daedalus" SYMLINK_LIB="yes" SYNC="rsync://rsync.gentoo.org/gentoo-portage" TERM="eterm-color" TEXINPUTS="/usr/lib64/ocaml/ocamldoc:" USE="X a52 aac acpi aim alsa amd64 ao apm bash-completion berkdb bluetooth bzip2 cairo caps cddb cdparanoia cdr cli cracklib crypt css cups curl dbus dri dvd dvdr emacs emboss encode exif fam ffmpeg fftw firefox flac fortran ftp fuse gdbm gif gmp gnome gpm gstreamer gtk gtk2 gtkhtml hal hardened iconv imap imlib ipod ipv6 isdnlog jabber java jpeg latex ldap libedit mad matroska midi mikmod mime mmap mp3 mpeg mplayer mudflap mule musepack ncurses nls nptl nptlonly nsplugin objc objc-gc ogg openmp pam pcmcia pcre pdf png ppds pppd python quicktime readline reflection sasl sdl session sharedmem sockets spell spl sqlite sqlite3 ssl svg tcpd theora threads tidy tiff truetype unicode usb vorbis wifi x264 xft xml xorg xpm xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="radeon" USER="root" USERLAND="GNU" USERNAME="root" USE_EXPAND="ALSA_CARDS ALSA_PCM_PLUGINS APACHE2_MODULES APACHE2_MPMS CAMERAS CROSSCOMPILE_OPTS DVB_CARDS ELIBC FCDSL_CARDS FOO2ZJS_DEVICES FRITZCAPI_CARDS INPUT_DEVICES KERNEL LCD_DEVICES LINGUAS LIRC_DEVICES MISDN_CARDS USERLAND VIDEO_CARDS" USE_EXPAND_HIDDEN="CROSSCOMPILE_OPTS ELIBC KERNEL USERLAND" USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d" VIDEO_CARDS="radeon" VMHANDLE="blackdown-jdk-1.4.2" WINDOWPATH="7" WMII_9MENU="wmii9menu -font -*-architect-medium-r-normal-*-11-* -nf #eeeeee -nb #000000 -sf #ff5500 -sb #151515 -br unusedn" WMII_ADDRESS="unix!/tmp/ns.daedalus.:0/wmii" WMII_CONFPATH="/home/daedalus/.wmii-3.5:/usr/local/etc/wmii-3.5" WMII_FOCUSCOLORS="#ffa000 #080840 #404099" WMII_FONT="-*-architect-medium-r-normal-*-11-*" WMII_MENU="dmenu -b -fn -*-architect-medium-r-normal-*-11-* -nf #eeeeee -nb #000000 -sf #ff5500 -sb #151515" WMII_NORMCOLORS="#dddddd #000000 #666666" WMII_NS_DIR="/tmp/ns.daedalus.:0" WMII_TERM="urxvt -e screen zsh" XAUTHORITY="/home/daedalus/.Xauthority" XDG_SESSION_COOKIE="" _="/usr/bin/sudo"
Created attachment 150339 [details] The preprocessed output.
The ICE-causing source file can be simplified even further. The following also causes an ICE: id obj; // Can be a pointer to *any* objc class type, or "id". int main(int argc, char **argv) { // Can be *any* function or method. obj = nil; // Can be *any* value. } I feel sure this has to be an error introduced somewhere in gentoo, as if it weren't, gcc would be unable to compile the vast majority of objective-c programs. It's also likely something that is particular to my configuration, though I have no idea what.
you can easily test your assumption by building gcc with USE=vanilla
Uh, *vast majority of objective c programs with -fobjc-gc. Most programs probably don't get compiled with -fobjc-gc; my bad. Anyway, I tested this with gcc-4.1.2 and got the same results; but on a different, gentoo-x86 machine, it compiled correctly under gcc-4.1.2. I then compiled gcc-4.2.3 with the vanilla USE flag, as suggested (thanks), and it still ICE'd. So apparently it's not some special patches gentoo is applying, but it does have to do with the architecture (x86 vs. x86-64).
gcc-4.3.0 on amd64 fails the same way
-fobjc-gc is only for the NeXTStep runtime. It's the documentation that needs fixing, not gcc itself.
An application segfaulting due to input is never acceptable. Its a bug in GCC, even if someone is using it incorrectly.
There's been no movement from upstream to fix this, so I'm closing it as LATER until they figure out what to do.
this should be fixed in gcc-4.5.2 now ...