From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#29183: 27.0.50; SIGSEGV on C-g on Windows Date: Wed, 8 Nov 2017 20:56:24 -0800 Organization: UCLA Computer Science Department Message-ID: References: <83mv3ysqth.fsf@gnu.org> <83d14tswq6.fsf@gnu.org> <834lq5saeu.fsf@gnu.org> <83wp30r48u.fsf@gnu.org> <571b940d-666b-c650-429d-5fc7bfc0d078@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------AE417FD1E58B50B65998EC35" X-Trace: blaine.gmane.org 1510203437 28228 195.159.176.226 (9 Nov 2017 04:57:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 9 Nov 2017 04:57:17 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 Cc: 29183@debbugs.gnu.org To: John Mastro Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 09 05:57:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCetq-00072Y-Ci for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Nov 2017 05:57:10 +0100 Original-Received: from localhost ([::1]:35106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCetx-0006B5-Hy for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 23:57:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCetl-0006Ao-UB for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 23:57:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCeti-0003IJ-QI for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 23:57:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50613) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCeti-0003I4-Lb for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 23:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eCeti-0004Gh-8d for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 23:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Nov 2017 04:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29183 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29183-submit@debbugs.gnu.org id=B29183.151020340216378 (code B ref 29183); Thu, 09 Nov 2017 04:57:02 +0000 Original-Received: (at 29183) by debbugs.gnu.org; 9 Nov 2017 04:56:42 +0000 Original-Received: from localhost ([127.0.0.1]:59294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCetM-0004G4-5b for submit@debbugs.gnu.org; Wed, 08 Nov 2017 23:56:40 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCetI-0004Fn-BT for 29183@debbugs.gnu.org; Wed, 08 Nov 2017 23:56:38 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 37A6416087C; Wed, 8 Nov 2017 20:56:30 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4O6CkHi47PMP; Wed, 8 Nov 2017 20:56:28 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AA3AD160887; Wed, 8 Nov 2017 20:56:28 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aGUWyKdi9Hfh; Wed, 8 Nov 2017 20:56:28 -0800 (PST) Original-Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 5609416087C; Wed, 8 Nov 2017 20:56:28 -0800 (PST) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139649 Archived-At: This is a multi-part message in MIME format. --------------AE417FD1E58B50B65998EC35 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable John Mastro wrote: > the only line in the diff between the two resulting > files that mentions main_thread is that the output from the source with > GCALIGNED says: >=20 > .lcomm main_thread,592,8 >=20 > Whereas the assembly output from the source without GCALIGNED says: >=20 > .lcomm main_thread,592,32 Thanks, this helped me see the problem. It turns out that 'struct foo=20 __attribute__ ((aligned (8)))' does not work with GCC, and that one must = put the=20 attribute somewhere else. This appears to be a bug in GCC, and I reported= the=20 GCC bug here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D82914 The workaround is easy: say 'struct __attribute__ ((aligned (8))) foo' in= stead.=20 I installed the attached patch into the emacs-26 branch and merged it int= o=20 master. Please give it a try. --------------AE417FD1E58B50B65998EC35 Content-Type: text/x-patch; name="0001-Use-GCALIGNED-properly-for-GCC.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Use-GCALIGNED-properly-for-GCC.patch" =46rom 9e59de9449b53c3ecd85b624c11360ba9cafee75 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 8 Nov 2017 19:11:18 -0800 Subject: [PATCH] Use GCALIGNED properly for GCC MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Apparently GCC requires that =E2=80=98__attribute__ ((aligned (8)))=E2=80= =99 must immediately follow the =E2=80=98struct=E2=80=99 keyword when aligning a s= tructure. The attribute silently does not work if it follows a tag after the =E2=80=98struct=E2=80=99 keyword. Who knew? Anyway, this patch is desig= ned to fix a SIGSEGV problem reported by John Mastro (Bug#29183). * lib-src/make-docfile.c (close_emacs_globals): * src/buffer.c (buffer_defaults, buffer_local_symbols): * src/lisp.h (DEFUN): * src/thread.c (main_thread): Put 'GCALIGNED' immediately after 'struct'. --- lib-src/make-docfile.c | 2 +- src/buffer.c | 4 ++-- src/lisp.h | 16 ++++++++++------ src/thread.c | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 0ea3f7b..ff84df9 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -668,7 +668,7 @@ close_emacs_globals (ptrdiff_t num_symbols) "extern\n" "#endif\n" "struct {\n" - " struct Lisp_Symbol GCALIGNED s;\n" + " struct GCALIGNED Lisp_Symbol s;\n" "} lispsym[%td];\n"), num_symbols); } diff --git a/src/buffer.c b/src/buffer.c index 15735a2..edeed55 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -61,7 +61,7 @@ struct buffer *all_buffers; Setting the default value also goes through the alist of buffers and stores into each buffer that does not say it has a local value. = */ =20 -struct buffer GCALIGNED buffer_defaults; +struct GCALIGNED buffer buffer_defaults; =20 /* This structure marks which slots in a buffer have corresponding default values in buffer_defaults. @@ -84,7 +84,7 @@ struct buffer buffer_local_flags; /* This structure holds the names of symbols whose values may be buffer-local. It is indexed and accessed in the same way as the abov= e. */ =20 -struct buffer GCALIGNED buffer_local_symbols; +struct GCALIGNED buffer buffer_local_symbols; =20 /* Return the symbol of the per-buffer variable at offset OFFSET in the buffer structure. */ diff --git a/src/lisp.h b/src/lisp.h index 4dd4720..0153468 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -277,10 +277,14 @@ DEFINE_GDB_SYMBOL_END (VALMASK) error !; #endif =20 -/* Declare an object to have an address that is a multiple of - GCALIGNMENT. This is a no-op if the object's natural alignment is - already a multiple of GCALIGNMENT. alignas is not suitable here, - as it fails if the object's natural alignment exceeds GCALIGNMENT. *= / +/* Use GCALIGNED immediately after the 'struct' keyword to require the + struct to have an address that is a multiple of GCALIGNMENT. This + is a no-op if the struct's natural alignment is already a multiple + of GCALIGNMENT. GCALIGNED's implementation uses the 'aligned' + attribute instead of 'alignas (GCALIGNMENT)', as the latter would + fail if an object's natural alignment exceeds GCALIGNMENT. The + implementation hopes that natural alignment suffices on platforms + lacking 'aligned'. */ #ifdef HAVE_STRUCT_ATTRIBUTE_ALIGNED # define GCALIGNED __attribute__ ((aligned (GCALIGNMENT))) #else @@ -2944,7 +2948,7 @@ CHECK_NUMBER_CDR (Lisp_Object x) #ifdef _MSC_VER #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ - static struct Lisp_Subr GCALIGNED sname =3D \ + static struct GCALIGNED Lisp_Subr sname =3D \ { { (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) \ | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)) }, \ { (Lisp_Object (__cdecl *)(void))fnname }, = \ @@ -2952,7 +2956,7 @@ CHECK_NUMBER_CDR (Lisp_Object x) Lisp_Object fnname #else /* not _MSC_VER */ #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ - static struct Lisp_Subr GCALIGNED sname =3D \ + static struct GCALIGNED Lisp_Subr sname =3D \ { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ { .a ## maxargs =3D fnname }, \ minargs, maxargs, lname, intspec, 0}; \ diff --git a/src/thread.c b/src/thread.c index 03f5b31..7335833 100644 --- a/src/thread.c +++ b/src/thread.c @@ -26,7 +26,7 @@ along with GNU Emacs. If not, see . */ #include "coding.h" #include "syssignal.h" =20 -static struct thread_state GCALIGNED main_thread; +static struct GCALIGNED thread_state main_thread; =20 struct thread_state *current_thread =3D &main_thread; =20 --=20 2.7.4 --------------AE417FD1E58B50B65998EC35--