Article View: gnu.emacs.bug
Article #99687Square peg in a round hole.
From: Simon Cooper
Date: Thu, 17 May 1990 05:34
Date: Thu, 17 May 1990 05:34
103 lines
4074 bytes
4074 bytes
You've probably had several reports + fixes to this bug - but here is my
contribution anyway.
Simon Cooper
-------------------------------------------------------------------------------
Snail-mail: Room F44, University of Cambridge, E-Mail: spc@uk.ac.cam.amtp.atm
DAMTP, Silver Street, Cambridge. spc11@uk.ac.cam.phx
CB3 9EW
Telephone: (+44) 223 337886 Fax: (+44) 223 337918
-------------------------------------------------------------------------------
GnuEmacs-Version: 18.55
C-Compiler: Gcc 1.37
Debugger: Gdb 3.4
Machine: Sun 4/60 (SPARCstation 1)
Operating-System: SunOs 4.0.3_EXPORT
Bug-Description:
./temacs bombs out with a "Bus error" in function "staticpro". This bug is
not attributable to Gcc - it generates correct code for the information given.
Other compilers may fall over.
When GDB is being used to debug ./temacs the following line is returned
(marked with =>)
--- 667,682 --- file: alloc.c -------------------------------------------------
char staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0};
int staticidx = 0;
#define staticvec ((Lisp_Object **) staticvec1)
/* Put an entry in staticvec, pointing at the variable whose address is given */
void
staticpro (varaddress)
Lisp_Object *varaddress;
{
=>staticvec[staticidx++] = varaddress;
if (staticidx >= NSTATICS)
abort ();
}
-------------------------------------------------------------------------------
staticvec is declared as a "char" rather than a "Lisp_Object *" and as such
can be skewed across a word boundary. A (Lisp_Object *) is of size word.
This is bad news since a Sparc cannot write a word across a word boundary =>
staticvec needs to be word aligned. GCC produces the following code
(disassembled via GDB) where <staticvec1> can be seen to have been allocated
an odd address 0x10d069 (thus causing word mis-alignment).
Starting program: /export/local/src/GnuEmacs-18.55/src/temacs -batch inc-vers
Program received signal 10, Bus error
0x31460 in staticpro (varaddress=(int *) 0x11e5d8) (alloc.c line 679)
(gdb) disass
Dump of assembler code from 0x31440 to 0x31480:
0x31440 <staticpro>: save %sp, -112, %sp
0x31444 <staticpro+4>: sethi %hi(0x10d000), %g1
0x31448 <staticpro+8>: ld [%g1+0x38c], %o0 ! 0x10d38c <staticidx>
0x3144c <staticpro+12>: add %o0, 1, %o1
0x31450 <staticpro+16>: st %o1, [%g1+0x38c]
0x31454 <staticpro+20>: sethi %hi(0x10d000), %o2
0x31458 <staticpro+24>: or %o2, 0x69, %o2 ! 0x10d069 <staticvec1>
0x3145c <staticpro+28>: sll %o0, 2, %o0
0x31460 <staticpro+32>: st %i0, [%o2+%o0]
0x31464 <staticpro+36>: cmp %o1, 0xc7
0x31468 <staticpro+40>: ble 0x31478 <staticpro+56>
0x3146c <staticpro+44>: nop
0x31470 <staticpro+48>: call 0xc8e30 <abort>
0x31474 <staticpro+52>: nop
0x31478 <staticpro+56>: ret
0x3147c <staticpro+60>: restore
End of assembler dump.
(gdb)
Fix:
Give the compiler enough information to align the array correctly.
*** alloc.c.~1~ Mon Feb 13 10:23:35 1989
--- alloc.c Thu May 17 05:28:13 1990
***************
*** 664,670 ****
#define NSTATICS 200
! char staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0};
int staticidx = 0;
--- 664,670 ----
#define NSTATICS 200
! Lisp_Object *staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0};
int staticidx = 0;
Technical Details
Message-ID:
<17059.9005170534@kelvin.amtp.cam.ac.uk>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!NSFNET-RELAY.AC.UK!spc%atmos-dynamics.damtp.cambridge.ac.ukShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,4b87206732bf1cd0,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-05-17 03:07:46 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!NSFNET-RELAY.AC.UK!spc%atmos-dynamics.damtp.cambridge.ac.uk From: spc%atmos-dynamics.damtp.cambridge.ac.uk@NSFNET-RELAY.AC.UK (Simon Cooper) Newsgroups: gnu.emacs.bug Subject: Square peg in a round hole. Message-ID: <17059.9005170534@kelvin.amtp.cam.ac.uk> Date: 17 May 90 05:34:44 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 103 Posted: Thu May 17 06:34:44 1990