[gnu.emacs.bug] The problem with GNU malloc and gcc found

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

In article <8906120152.AA00707@cs.hut.fi>, I write:
>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.

I found the problem; it appears that the Altos C compiler returns
pointers in a0 instead of d0 as gcc does.  So, when fgets() from the
Altos c library calls malloc() to allocate some memory, it thinks that
malloc() returns the value in a0, which actually contains garbage.
After this, when the garbage value is used and free()ed, free() of
course complains about this.

So I guess I'll have a look at how to configure gcc to return pointers
both in d0 and a0; this is what the altos cc does.

//Jyrki