GNU bug report logs -
#29040
emacs-26 crash due to misaligned longjmp buffer in 64-bit MSYS2/MinGW-W64 build
Previous Next
Reported by: Richard Copley <rcopley <at> gmail.com>
Date: Sat, 28 Oct 2017 13:42:02 UTC
Severity: normal
Tags: fixed
Done: Richard Copley <rcopley <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Cc: rcopley <at> gmail.com, 29040 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Wed, 1 Nov 2017 23:02:39 -0700
>
> > +#define THREAD_ALIGNMENT COMMON_MULTIPLE (alignof (max_align_t), GCALIGNMENT)
> > +
> > +static struct thread_state alignas (THREAD_ALIGNMENT) main_thread;
>
> Three questions:
>
> The Gnulib manual
> <https://www.gnu.org/software/gnulib/manual/html_node/stdalign_002eh.html> says,
> "Some compilers require the operand of _Alignas/alignas to be a single integer
> constant, not an expression: MSVC 7.0 through at least 10.0." (Also,
> <https://stackoverflow.com/questions/7895869/cross-platform-alignx-macro>
> suggests that this issue may also occur with VS2013, though VS2015 should be OK
> since it supports alignas.) Are any of these older compilers of concern when
> building Emacs? If so, the above change won't work for them.
We've stopped supporting MSVC long ago. Only GCC is supported for
building on MS-Windows.
> Why does the above code use 'alignof (max_align_t)' rather than 'alignof (struct
> thread_state)'? Doesn't the latter suffice?
No special reason, I just did the same as you did in aligning
pseudovectors, when we had a similar problem the last time. Feel free
to change if you think it's better.
> C11 requires that a compiler must issue a diagnostic for a declaration like
> 'struct thread_state alignas (8) foo;' if the alignment of plain 'struct state'
> is greater than 8. Can I take it from this bug report that the Microsoft
> compilers do not conform to that part of the standard? If so, we should add
> checks to verify this requirement where it is assumed elsewhere.
Again, this is GCC, so what MS compilers do is not interesting.
The problem was caused by your changes in 015f0bb, which were for
OpenVMS:
diff --git a/src/thread.c b/src/thread.c
index c03cdda..6f12d79 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "coding.h"
#include "syssignal.h"
-static struct thread_state main_thread;
+static struct thread_state alignas (GCALIGNMENT) main_thread;
struct thread_state *current_thread = &main_thread;
This downgraded the alignment on 64-bit MS-Windows hosts, so I
upgraded it back. If using alignas with an argument > 8 is
non-portable, then I guess we will have to make your OpenVMS fix
conditional on just that platform. Or do you see a cleaner fix?
This bug report was last modified 7 years and 208 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.