Subject: Re: bug#29040: Emacs 25 hangs on windows arbitrarily during search of a unicode file

From: Richard Copley <[email-masked]>
Date: Sat, 28 Oct 2017 17:16:14 +0100

On 28 October 2017 at 16:58, Eli Zaretskii <[email-masked]> wrote:
>> Date: Sat, 28 Oct 2017 17:14:14 +0300
>> From: Eli Zaretskii <[email-masked]>
>> Cc: [email-masked]
>>
>> I'm not saying that this is a GCC bug.  But maybe you are right, and
>> the changes in d7038020 exposed this problem.
>
> Actually, I think it was caused by 015f0bb.  Does the patch below fix
> the problem?  Please actually check the alignment of getcjmp, not just
> that the crashes went away.
>
> diff --git a/src/thread.c b/src/thread.c
> index 6f12d79..2520771 100644
> --- a/src/thread.c
> +++ b/src/thread.c
> @@ -26,7 +26,11 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
>  #include "coding.h"
>  #include "syssignal.h"
>
> -static struct thread_state alignas (GCALIGNMENT) main_thread;
> +#define COMMON_MULTIPLE(a, b) \
> +  ((a) % (b) == 0 ? (a) : (b) % (a) == 0 ? (b) : (a) * (b))
> +#define THREAD_ALIGNMENT COMMON_MULTIPLE (alignof (max_align_t), GCALIGNMENT)
> +
> +static struct thread_state alignas (THREAD_ALIGNMENT) main_thread;
>
>  struct thread_state *current_thread = &main_thread;

Looks good. There's no crash and getcjmp is aligned:

Thread 1 hit Breakpoint 3, quit_throw_to_read_char (
    from_signal=from_signal@entry=false) at keyboard.c:10548
10548     sys_longjmp (getcjmp, 1);
(gdb) p &getcjmp
$1 = (sys_jmp_buf *) 0x4005cdaf0 <main_thread+224>

My message to MinGW-W64 was held up for moderation. I have cancelled it.
Thanks.