* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
@ 2013-01-01 21:51 Mikael Pettersson
2013-01-02 3:12 ` Paul Eggert
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mikael Pettersson @ 2013-01-01 21:51 UTC (permalink / raw
To: 13332; +Cc: Mikael Pettersson
Attempting to bootstrap Emacs 23.x or 24.x on Linux/M68K fails with
a SEGV as soon as temacs is run. Inspecting the core dump shows:
Core was generated by `/home/mikpe/emacs-24.2/build-nox/src/temacs --batch --load loadu'.
Program terminated with signal 11, Segmentation fault.
#0 0x800d5444 in mark_object (arg=1174437910) at /home/mikpe/emacs-24.2/src/alloc.c:5720
5720 if (CONS_MARKED_P (ptr))
(gdb) bt
#0 0x800d5444 in mark_object (arg=1174437910) at /home/mikpe/emacs-24.2/src/alloc.c:5720
#1 0x800d55ba in mark_object (arg=-2143958762) at /home/mikpe/emacs-24.2/src/alloc.c:5731
#2 0x800d5c3a in mark_vectorlike (ptr=0x8035b120) at /home/mikpe/emacs-24.2/src/alloc.c:5420
#3 0x800d5d62 in Fgarbage_collect () at /home/mikpe/emacs-24.2/src/alloc.c:5128
#4 0x800eb7be in Ffuncall (nargs=3, args=0xefcdfad4) at /home/mikpe/emacs-24.2/src/eval.c:2938
#5 0x800ebc46 in call2 (fn=0, arg1=0, arg2=-2143972138) at /home/mikpe/emacs-24.2/src/eval.c:2785
#6 0x800ebf82 in Fsignal (error_symbol=0, data=-2143972138) at /home/mikpe/emacs-24.2/src/eval.c:1710
#7 0x800ec412 in xsignal (error_symbol=0, data=-2143972138) at /home/mikpe/emacs-24.2/src/eval.c:1785
#8 0x800ecdc8 in xsignal1 (error_symbol=0, arg=-2143955495) at /home/mikpe/emacs-24.2/src/eval.c:1800
#9 0x800ece32 in verror (m=0x8015f90d "Bad data in guts of obarray", ap=0xefce0b24) at /home/mikpe/emacs-24.2/src/eval.c:1998
#10 0x800ece44 in error (m=0x8015f90d "Bad data in guts of obarray") at /home/mikpe/emacs-24.2/src/eval.c:2010
#11 0x80108eec in oblookup (obarray=<optimized out>, ptr=0x80156383 "char-table-extra-slots", size=22, size_byte=22) at /home/mikpe/emacs-24.2/src/lread.c:3912
#12 0x8010c578 in intern_c_string (str=0x80156383 "char-table-extra-slots") at /home/mikpe/emacs-24.2/src/lread.c:3728
#13 0x8005ce76 in init_category_once () at /home/mikpe/emacs-24.2/src/category.c:461
#14 0x80006558 in main (argc=<optimized out>, argv=0xefce0ef4) at /home/mikpe/emacs-24.2/src/emacs.c:1265
(gdb) q
This turns out to be caused by the well-known issue of data alignment
on Linux/M68K: the ABI only aligns 32-bit (and larger) primitive types
to 16-bit boundaries, which doesn't provide enough known-zero bits in
object pointers for Emacs' tagging scheme, causing major confusion and
breakage at runtime.
This patch introduces two new integer types in src/m/m68k.h that are
exactly like int and unsigned int, except they are explicitly aligned
to 32-bit boundaries; gcc's attribute aligned is used for this purpose.
It then defines EMACS_INT and EMACS_UINT to these types to override the
default choices in src/lisp.h.
With this patch in place bootstrap succeeds and the final emacs
executable works fine. Tested with Emacs-24.2 on Linux/M68K.
/Mikael Pettersson
[I consider this 6-line patch (not counting the comment) to be trivial so
I hope it will be acceptable even without a formal copyright assignment.]
src/ChangeLog:
2013-01-01 Mikael Pettersson <mikpe@it.uu.se>
* m/m68k.h [GNU_LINUX] (m68k_aligned_int_t, m68k_aligned_uint_t):
New typedefs.
(EMACS_INT, EMACS_UINT, BITS_PER_EMACS_INT, pI): Define.
--- emacs-24.2/src/m/m68k.h.~1~ 2012-08-23 07:33:42.000000000 +0200
+++ emacs-24.2/src/m/m68k.h 2013-01-01 14:26:10.000000000 +0100
@@ -28,5 +28,19 @@ along with GNU Emacs. If not, see <http
#define DATA_SEG_BITS 0x80000000
#endif
+/* Define the type to use.
+ Emacs cannot use the default type (plain int) since the ABI on
+ Linux/M68K only aligns 32-bit (and larger) primitive types to
+ 16-bit boundaries. Define new explicitly aligned integer types
+ and use them for EMACS_INT and EMACS_UINT. Compiling Emacs
+ with -malign-int does not work since it changes data layout in
+ external interfaces (system calls, libraries). */
+typedef int m68k_aligned_int_t __attribute__ ((__aligned__ (4)));
+typedef unsigned int m68k_aligned_uint_t __attribute__ ((__aligned__ (4)));
+#define EMACS_INT m68k_aligned_int_t
+#define EMACS_UINT m68k_aligned_uint_t
+#define BITS_PER_EMACS_INT 32
+#define pI ""
+
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
2013-01-01 21:51 bug#13332: [PATCH] unbreak Emacs on Linux/M68K Mikael Pettersson
@ 2013-01-02 3:12 ` Paul Eggert
2013-01-02 10:12 ` Andreas Schwab
2013-01-02 16:10 ` Andreas Schwab
2 siblings, 0 replies; 6+ messages in thread
From: Paul Eggert @ 2013-01-02 3:12 UTC (permalink / raw
To: Mikael Pettersson; +Cc: 13332
This part of Emacs has changed in the trunk -- there's no longer
an m/m68k.h file. But more important, can you explain more why the
patch is needed, and how it works? First, Emacs shouldn't require
any particular alignment for EMACS_INT: the alignment requirements
are on the larger objects that Emacs allocates, not on EMACS_INT
per se. Second, even if there's a bug in Emacs where it's
incorrectly assuming that EMACS_INT is aligned, I would expect it
to require an alignment of 8, not of 4, since Emacs uses 3 tag
bits, not 2.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
2013-01-01 21:51 bug#13332: [PATCH] unbreak Emacs on Linux/M68K Mikael Pettersson
2013-01-02 3:12 ` Paul Eggert
@ 2013-01-02 10:12 ` Andreas Schwab
2013-01-02 16:33 ` Andreas Schwab
2013-01-02 16:10 ` Andreas Schwab
2 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-01-02 10:12 UTC (permalink / raw
To: Mikael Pettersson; +Cc: 13332
The last time I tested emacs on m68k (about 8 months ago, before 24.2)
it worked fine after I've fixed an alignment bug, see commit d2220b5.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
2013-01-01 21:51 bug#13332: [PATCH] unbreak Emacs on Linux/M68K Mikael Pettersson
2013-01-02 3:12 ` Paul Eggert
2013-01-02 10:12 ` Andreas Schwab
@ 2013-01-02 16:10 ` Andreas Schwab
2 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2013-01-02 16:10 UTC (permalink / raw
To: Mikael Pettersson; +Cc: 13332
Both emacs-24 and trunk are working fine for me.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
2013-01-02 10:12 ` Andreas Schwab
@ 2013-01-02 16:33 ` Andreas Schwab
2013-01-02 22:38 ` Mikael Pettersson
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-01-02 16:33 UTC (permalink / raw
To: Mikael Pettersson; +Cc: 13332-done
I just noticed that the commit didn't make it into 24.2. But it should
be easy enough to backport for any interested parties.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#13332: [PATCH] unbreak Emacs on Linux/M68K
2013-01-02 16:33 ` Andreas Schwab
@ 2013-01-02 22:38 ` Mikael Pettersson
0 siblings, 0 replies; 6+ messages in thread
From: Mikael Pettersson @ 2013-01-02 22:38 UTC (permalink / raw
To: Andreas Schwab; +Cc: Mikael Pettersson, 13332-done
Andreas Schwab writes:
> I just noticed that the commit didn't make it into 24.2. But it should
> be easy enough to backport for any interested parties.
I spotted three alignment-related trunk commits around that time:
f17846357a5b00985131f1766dc705efa995191f
d2220b5dc1122f7ee597d26f5ce874a768be9b08
68be74b0a5c9cdac93f4f1d19760925dd3d264ed
I can confirm that applying all three to 24.2 unbreaks it on m68k.
Case closed.
/Mikael
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-02 22:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-01 21:51 bug#13332: [PATCH] unbreak Emacs on Linux/M68K Mikael Pettersson
2013-01-02 3:12 ` Paul Eggert
2013-01-02 10:12 ` Andreas Schwab
2013-01-02 16:33 ` Andreas Schwab
2013-01-02 22:38 ` Mikael Pettersson
2013-01-02 16:10 ` Andreas Schwab
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.