Subject: gcc 4.5 breaks optimized builds of emacs

From: Elias Pipping <[email-masked]>
Date: Sun, 25 Apr 2010 01:44:14 +0200

Hi,

I'm on the current HEAD of the repo.or.cz mirror of emacs which is

  http://repo.or.cz/w/emacs.git/commit/910daaa95ca0708ad7022667e214bba4b8eb3d6b

When I compile a minimal version of emacs like this:

  $ ./configure CFLAGS="-O1 -foptimize-sibling-calls" --without-x
--without-alsa --without-dbus; [..]

with gcc 4.5 and run it via

  $ ./src/emacs -Q -nw

I get a segfault. Dropping the -foptimize-sibling-calls (which is
implied by -O2) makes it work again. So does using an older version of
gcc (e.g. 4.4.3) or running emacs outside a terminal.

$ gdb ./src/emacs
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/pipping/emacs/src/emacs...done.
(gdb) run -Q -nw

< clears terminal >

Program received signal SIGSEGV, Segmentation fault.
0x0000000000406015 in fill_up_glyph_row_area_with_spaces
(row=0x111e320, area=2) at dispnew.c:2910
2910            *text++ = space_glyph;
(gdb) bt
#0  0x0000000000406015 in fill_up_glyph_row_area_with_spaces
(row=0x111e320, area=2) at dispnew.c:2910
#1  0x000000000040a6a8 in fill_up_glyph_row_with_spaces
(matrix=0xde7290, w=0xb4a630) at dispnew.c:2892
#2  build_frame_matrix_from_leaf_window (matrix=0xde7290, w=0xb4a630)
at dispnew.c:2790
#3  build_frame_matrix_from_window_tree (matrix=0xde7290, w=0xb4a630)
at dispnew.c:2718
#4  0x000000000040c51c in build_frame_matrix (f=0xb4a3b0, force_p=1,
inhibit_hairy_id_p=1) at dispnew.c:2698
#5  update_frame (f=0xb4a3b0, force_p=1, inhibit_hairy_id_p=1) at dispnew.c:3560
#6  0x0000000000426340 in echo_area_display (update_frame_p=1) at xdisp.c:9624
#7  0x0000000000426601 in message3_nolog (m=16043489, nbytes=65,
multibyte=0) at xdisp.c:8479
#8  0x00000000004267d0 in message3 (m=16043489, nbytes=65,
multibyte=0) at xdisp.c:8414
#9  0x00000000004d3bf7 in Fmessage (nargs=<value optimized out>,
args=<value optimized out>) at editfns.c:3408
#10 0x00000000004d976c in Ffuncall (nargs=<value optimized out>,
args=0x7fffffffd510) at eval.c:3054
#11 0x000000000050bde9 in Fbyte_code (bytestr=<value optimized out>,
vector=<value optimized out>, maxdepth=<value optimized out>) at
bytecode.c:680
#12 0x00000000004dbca2 in funcall_lambda (fun=8298757, nargs=0,
arg_vector=0x7fffffffd6d8) at eval.c:3260
#13 0x00000000004d9949 in Ffuncall (nargs=<value optimized out>,
args=0x7fffffffd6d0) at eval.c:3119
#14 0x000000000050bde9 in Fbyte_code (bytestr=<value optimized out>,
vector=<value optimized out>, maxdepth=<value optimized out>) at
bytecode.c:680
#15 0x00000000004dbca2 in funcall_lambda (fun=8300205, nargs=1,
arg_vector=0x7fffffffd8c8) at eval.c:3260
#16 0x00000000004d9949 in Ffuncall (nargs=<value optimized out>,
args=0x7fffffffd8c0) at eval.c:3119
#17 0x000000000050bde9 in Fbyte_code (bytestr=<value optimized out>,
vector=<value optimized out>, maxdepth=<value optimized out>) at
bytecode.c:680
#18 0x00000000004dbca2 in funcall_lambda (fun=8273333, nargs=0,
arg_vector=0x7fffffffdaa8) at eval.c:3260
#19 0x00000000004d9949 in Ffuncall (nargs=<value optimized out>,
args=0x7fffffffdaa0) at eval.c:3119
#20 0x000000000050bde9 in Fbyte_code (bytestr=<value optimized out>,
vector=<value optimized out>, maxdepth=<value optimized out>) at
bytecode.c:680
#21 0x00000000004dbca2 in funcall_lambda (fun=8268357, nargs=0,
arg_vector=0x7fffffffdbe0) at eval.c:3260
#22 0x00000000004dbd87 in apply_lambda (fun=8268357, args=<value
optimized out>, eval_flag=1) at eval.c:3184
#23 0x00000000004db750 in Feval (form=<value optimized out>) at eval.c:2410
#24 0x00000000004d8dc4 in internal_condition_case (bfun=0x474709
<top_level_2>, handlers=11756482, hfun=0x474faf <cmd_error>) at
eval.c:1512
#25 0x0000000000474bdb in top_level_1 () at keyboard.c:1373
#26 0x00000000004d8c94 in internal_catch (tag=11752306, func=0x474bb1
<top_level_1>, arg=11704658) at eval.c:1248
#27 0x000000000047513a in command_loop () at keyboard.c:1328
#28 0x00000000004751ee in recursive_edit_1 () at keyboard.c:950
#29 0x0000000000475338 in Frecursive_edit () at keyboard.c:1012
#30 0x0000000000472747 in main (argc=<value optimized out>,
argv=0x7fffffffe418) at emacs.c:1784
(gdb)

Kind Regards,

Elias Pipping