Subject: 24.2.50; when compiled with optimisation and LLVM GCC temacs crashes
From: Peter Dyballa <[email-masked]>
To: [email-masked]
Date: Sun, 2 Sep 2012 21:55:46 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

Configured as

In GNU Emacs 24.2.50.1 (i386-apple-darwin10.8.0, X toolkit, Xaw3d scroll bars)
 of 2012-09-02 on Sumac.local
Bzr revision: 109859 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.11299905
Configured using:
 `configure '--build=x86_64-apple-darwin10.8.0'
 '--host=i386-apple-darwin10.8.0' '--target=i386-apple-darwin10.8.0'
 '--with-wide-int' '--without-pop' '--without-sound' '--without-gconf'
 '--without-gpm' '--without-dbus' '--without-selinux'
 '--with-x-toolkit=athena' '--disable-ns-self-contained' '--without-xpm'
 '--without-jpeg' '--without-tiff' '--without-gif' '--without-png'
 '--without-rsvg' '--x-libraries=/usr/X11/lib'
 '--x-includes=/usr/X11/include'
 '--enable-locallisppath=/Library/Application
 Support/Emacs/calendar24:/Library/Application Support/Emacs' 'CFLAGS=-g
 -H -pipe -fPIC -fno-common -O1 -m32 -fomit-frame-pointer -msse3
 -foptimize-register-move -ftree-vectorize' 'CPPFLAGS=-I/sw/include'
 'LDFLAGS=-L/sw/lib -m32 -Wl,-dead_strip_dylibs -Wl,-bind_at_load
 -Wl,-t' 'CC=llvm-gcc-4.2' 'CXX=llvm-g++-4.2'
 'PKG_CONFIG_PATH=/sw/lib/xft2/lib/pkgconfig:/sw/share/pkgconfig:/sw/lib/pkgconfig:/usr/X11/lib/pkgconfig:/usr/X11/share/pkgconfig:/usr/lib/pkgconfig'
 'build_alias=x86_64-apple-darwin10.8.0'
 'host_alias=i386-apple-darwin10.8.0'
 'target_alias=i386-apple-darwin10.8.0''

to get a 32-bit application in a 32-bit software environment on 64-bit hardware (Mac OS X 10.6.8 on intel Core i7/Sandy Bridge) it works with -O0 and -O1. More optimisation lets temacs crash:

	/bin/sh: line 1: 87445 Segmentation fault      (core dumped) `/bin/pwd`/temacs --batch --load loadup bootstrap
	make[2]: *** [bootstrap-emacs] Error 1
	make[1]: *** [src] Error 2
	make: *** [bootstrap] Error 2

When I run temacs with these arguments in gud-gdb I get:

	Starting program: .../emacs-24.2.50/src/temacs '--batch --load loadup bootstrap'
	Im Emacs
	Reading symbols for shared libraries .+++++++++++++++++++..... done
	Loading loadup.el (source)...
	
	Program received signal EXC_BAD_ACCESS, Could not access memory.
	Reason: KERN_INVALID_ADDRESS at address: 0xfffffeec
	0x0016998f in mark_maybe_pointer [inlined] () at .../emacs-24.2.50/src/alloc.c:4617
	(gdb) bt full
	#0  0x0016998f in mark_maybe_pointer [inlined] () at .../emacs-24.2.50/src/alloc.c:4617
		tem = (void *) #1  0x0016998f in mark_memory [inlined] () at .../emacs-24.2.50/src/alloc.c:4700
		tem = (void *) #2  0x0016998f in Fgarbage_collect () at alloc.c:4939
		tem = (void *) 
	Lisp Backtrace:
	No symbol "VALMASK" in current context.
	(gdb) xbacktrace
	No symbol "VALMASK" in current context.

In another window arc/alloc.c is displayed with a mark pointing onto line #4617 with

	mark_object (obj);

The compilation of alloc.c goes like this (recompiling after deleting src/alloc.o):

make[2]: Nothing to be done for `all'.
llvm-gcc-4.2 -std=gnu99 -c -I/sw/include -Demacs  -I. -I/Users/pete/Quellen/Emacs_CVS/emacs-24.2.50/src -I../lib -I/Users/pete/Quellen/Emacs_CVS/emacs-24.2.50/src/../lib   -I/usr/X11/include -I/sw/include -I/sw/include/freetype2 -I/usr/X11/include -I/usr/X11R6/include    -I/sw/include/ImageMagick -fopenmp -I/sw/include/libxml2 -I/sw/include   -I/sw/include/freetype2 -I/sw/include -I/sw/include   -I/sw/include/freetype2 -I/sw/include -I/sw/include   -MMD -MF deps/alloc.d -MP  -I/sw/include     -g -ggdb -H -pipe -fPIC -fno-common -O2 -m32 -fomit-frame-pointer -msse3 -foptimize-register-move -ftree-vectorize alloc.c
. ./config.h
.. ./conf_post.h
... ../lib/alloca.h
... /usr/include/string.h
.... /usr/include/_types.h
..... /usr/include/sys/_types.h
...... /usr/include/sys/cdefs.h
...... /usr/include/machine/_types.h
....... /usr/include/i386/_types.h
.... /usr/include/secure/_string.h
..... /usr/include/secure/_common.h
... ../lib/stdlib.h
.... /usr/include/stdlib.h
..... /usr/include/Availability.h
...... /usr/include/AvailabilityInternal.h
..... /usr/include/sys/wait.h
...... /usr/include/sys/signal.h
....... /usr/include/sys/appleapiopts.h
....... /usr/include/machine/signal.h
........ /usr/include/i386/signal.h
......... /usr/include/i386/_structs.h
....... /usr/include/sys/_structs.h
........ /usr/include/machine/_structs.h
......... /usr/include/i386/_structs.h
.......... /usr/include/mach/i386/_structs.h
...... /usr/include/sys/resource.h
....... /usr/include/sys/_structs.h
...... /usr/include/machine/endian.h
....... /usr/include/i386/endian.h
........ /usr/include/sys/_endian.h
......... /usr/include/libkern/_OSByteOrder.h
.......... /usr/include/libkern/i386/_OSByteOrder.h
..... /usr/include/machine/types.h
...... /usr/include/i386/types.h
....... /usr/include/i386/_types.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
. ../lib/stdio.h
.. /usr/include/stdio.h
... /usr/include/secure/_stdio.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stdarg.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
.. /usr/include/sys/types.h
... /usr/include/sys/_structs.h
. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.. /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
... /usr/include/limits.h
.... /usr/include/machine/limits.h
..... /usr/include/i386/limits.h
...... /usr/include/i386/_limits.h
.... /usr/include/sys/syslimits.h
. /usr/include/setjmp.h
.. /usr/include/machine/setjmp.h
... /usr/include/i386/setjmp.h
. ../lib/signal.h
.. /usr/include/signal.h
.. /usr/include/pthread.h
... /usr/include/pthread_impl.h
... /usr/include/sched.h
... ../lib/time.h
.... /usr/include/time.h
..... /usr/include/_structs.h
...... /usr/include/sys/_structs.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
. lisp.h
.. ../lib/stdalign.h
... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stdbool.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
.. ../lib/inttypes.h
... /usr/include/inttypes.h
.... ../lib/stdint.h
..... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stdint.h
..... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
...... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
...... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
....... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
..... ../lib/inttypes.h
...... /usr/include/inttypes.h
... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
..... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.. /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
.... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.. ../lib/intprops.h
... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/limits.h
..... /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include/syslimits.h
.. globals.h
. process.h
.. ../lib/unistd.h
... /usr/include/unistd.h
.... /usr/include/sys/unistd.h
.... ../lib/sys/select.h
..... ../lib/sys/time.h
...... /usr/include/sys/time.h
....... /usr/include/sys/_structs.h
....... ../lib/time.h
....... /usr/include/sys/_select.h
..... /usr/include/sys/select.h
...... /usr/include/sys/_structs.h
..... ../lib/signal.h
... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
... ../lib/stdlib.h
... ../lib/getopt.h
.... /usr/include/getopt.h
..... ../lib/unistd.h
.... /usr/include/ctype.h
..... /usr/include/runetype.h
... /usr/include/crt_externs.h
.. gnutls.h
... /sw/include/gnutls/gnutls.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
.... ../lib/time.h
.... /sw/include/gnutls/compat.h
... /sw/include/gnutls/x509.h
. intervals.h
.. dispextern.h
... /usr/X11/include/X11/Xlib.h
.... /usr/X11/include/X11/X.h
.... /usr/X11/include/X11/Xfuncproto.h
.... /usr/X11/include/X11/Xosdefs.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
... /usr/X11/include/X11/Intrinsic.h
.... /usr/X11/include/X11/Xutil.h
..... /usr/X11/include/X11/keysym.h
...... /usr/X11/include/X11/keysymdef.h
.... /usr/X11/include/X11/Xresource.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
.... /usr/X11/include/X11/Core.h
.... /usr/X11/include/X11/Composite.h
.... /usr/X11/include/X11/Constraint.h
.... /usr/X11/include/X11/Object.h
.... /usr/X11/include/X11/RectObj.h
... ../lib/c-strcase.h
.... /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin10/4.2.1/include/stddef.h
... systime.h
.... ../lib/timespec.h
..... ../lib/time.h
.... ../lib/sys/time.h
.. composite.h
. puresize.h
. character.h
.. ../lib/verify.h
. buffer.h
. window.h
. keyboard.h
.. coding.h
. frame.h
. blockinput.h
.. atimer.h
. syssignal.h
. termhooks.h
. ../lib/unistd.h
. /usr/include/fcntl.h
.. /usr/include/sys/fcntl.h
alloc.c: In function ‘allocate_vector’:
alloc.c:3250: warning: comparison is always true due to limited range of data type

Compiling with -g -ggdb does not bring more insight from gdb…

--
Mit friedvollen Grüßen

  Pete

When confronted with actual numbers, a mathematician is at a loss.
				– Steffen Hokland