Subject: Emacs crash when building with --enable-checking on Mac OS X

From: Ben Key <[email-masked]>
Date: Wed, 6 Apr 2011 21:37:42 -0500

When Emacs is configured with --enable-checking=xmallocoverrun on Mac OS X,
Emacs crashes during the build process.  The error is as follows.

temacs(20348,0x7fff70e01ca0) malloc: *** error for object 0x10076c010:
Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
/bin/sh: line 1: 20348 Abort trap              `/bin/pwd`/temacs --batch
--load loadup bootstrap
make[1]: *** [bootstrap-emacs] Error 1

Note that I set attempted to debug the problem with gdb.  I set a breakpoint
in malloc_error_break as directed by the error message.  The resulting
backtrace is as follows.

#0  0x00007fff86eed779 in malloc_error_break ()
#1  0x00007fff86eee8d0 in szone_error ()
#2  0x000000010020205a in unexec_free (ptr=0x10076c018) at unexmacosx.c:1384
#3  0x0000000100091387 in Fclear_charset_maps () at charset.c:2141
#4  0x00000001001a4b7a in eval_sub (form=4337996870) at eval.c:2360
#5  0x00000001001d7241 in readevalloop (readcharfun=4320321402,
stream=0x7fff70e03f40, sourcename=4320479449, printflag=0,
unibyte=4320145482, readfun=4320145482, start=4320145482, end=4320145482) at
lread.c:1806
#6  0x00000001001d5722 in Fload (file=4320479193, noerror=4320145482,
nomessage=4320145482, nosuffix=4320145482, must_suffix=4320145482) at
lread.c:1284
#7  0x00000001001a4c5a in eval_sub (form=4320150710) at eval.c:2377
#8  0x00000001001a439b in Feval (form=4320150710, lexical=4320145482) at
eval.c:2213
#9  0x00000001000f06c1 in top_level_2 () at keyboard.c:1137
#10 0x00000001001a2a83 in internal_condition_case (bfun=0x1000f06a0
<top_level_2>, handlers=4320211690, hfun=0x1000f0169 <cmd_error>) at
eval.c:1491
#11 0x00000001000f0709 in top_level_1 (ignore=4320145482) at keyboard.c:1145
#12 0x00000001001a23b1 in internal_catch (tag=4320206362, func=0x1000f06c3
<top_level_1>, arg=4320145482) at eval.c:1238
#13 0x00000001000f0603 in command_loop () at keyboard.c:1100
#14 0x00000001000efbf1 in recursive_edit_1 () at keyboard.c:730
#15 0x00000001000efded in Frecursive_edit () at keyboard.c:792
#16 0x00000001000edd46 in main (argc=5, argv=0x7fff5fbff9c8) at emacs.c:1685

Steps to reproduce:

1.  Configure Emacs using the following command on Mac OS X.
    ./configure --enable-checking=xmallocoverrun --with-ns CFLAGS='-g3 -O0'
2.  Build Emacs using the following command.
    make install
3.  Emacs crashes when " `/bin/pwd`/temacs --batch --load loadup bootstrap"
is called.