[gnu.emacs.bug] Trouble with GNU malloc when compiled with gcc

jkp@SAUNA.HUT.FI (Jyrki Kuoppala) (06/12/89)

When compiling emacs 18.54 (or actually any GNU program with GNU
malloc) the program core dumps if malloc.c is compiled with gcc.  It
doesn't matter if malloc is compiled with -O or not.  When malloc is
compiled with cc, everything works fine.

Environment: gcc 1.35, emacs 18.54 (or newest GDB), Altos 3068 (m68k
running USG5.2.2).

The problem seems kind of strange, since it appears only on the Altos;
on m68k-suns, 68030-sonys, sparcs and vaxen it works fine.

This has bothered me for a while, I think as long as I have used gcc
(gcc 1.33 or earlier ?).  Also, it appears when compiling tcsh which
has a malloc based on the same one as the GNU malloc.

Here some debugger output from compiling emacs, I'll be glad to give
more information.  malloc.c was compiled without -O and botch(x)
defined as (perror(x), abort()).

Current directory is /u2/gnu/dist-18.54/src/
GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /u2/gnu/dist-18.54/src/temacs...done.
Undefined command: "unset-e".
Type "help" for a list of commands.
(gdb) r -batch -l inc-vers
Starting program: /u2/gnu/dist-18.54/src/temacs -batch -l inc-vers
Loading inc-vers...
free: Called with bad argument
: Bad address

Program received signal 6, SIGIOT
0x36e1a in kill ()
(gdb) bt
#0  0x36e1a in kill ()
#1  0x35896 in abort ()
#2  0x3438e in free (mem=(char *) 0x8741b ";; Load this file to increment the recorded Emacs version number.\n;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is distributed in the hop"...) (malloc.c line 566)
#3  0x37394 in fclose ()
#4  0x3730a in _cleanup ()
#5  0x35882 in abort ()
#6  0x3438e in free (mem=(char *) 0x8741b ";; Load this file to increment the recorded Emacs version number.\n;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is distributed in the hop"...) (malloc.c line 566)
#7  0x37394 in fclose ()
#8  0x2ae12 in load_unwind (...) (...)
#9  0x26f64 in unbind_to (...) (...)
#10 0x2adb4 in Fload (...) (...)
#11 0x26318 in Feval (...) (...)
#12 0xb164 in top_level_2 (...) (...)
#13 0x257be in internal_condition_case (...) (...)
#14 0xb1ec in top_level_1 (...) (...)
#15 0x253a6 in internal_catch (...) (...)
#16 0xb0ec in command_loop (...) (...)
#17 0xae34 in Frecursive_edit (...) (...)
#18 0xa83e in main (...) (...)
(gdb) frame 6
#6  0x3438e in free (mem=(char *) 0x8741b ";; Load this file to increment the recorded Emacs version number.\n;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is distributed in the hop"...) (malloc.c line 566)
(gdb) print p
$4 = (struct mhead *) 0x7313a
(gdb) print *p
$5 = {mh_alloc = 0 '\000', mh_index = 0 '\000', mh_size = 0, mh_nbytes = 554011, mh_magic4 = 554011}
(gdb) 

And this is where the malloc crashes (botch is defined as perror(x),abort())


	  botch ("free: Called with already freed block argument\n");
	else
=>	  botch ("free: Called with bad argument\n");
      }