On 2017/3/8 11:27, Liu Hao wrote:
On 2017/3/8 4:31, Mateusz Mikuła wrote:
Forwarding Aleksey's message from MSYS2 discussion:
[...]
W dniu 22.01.2017 o 11:36, Adrien Nader pisze:
Hi,

I've recently re-stumbled upon this. As far as I can tell it hasn't been
commited. Was there some more discussion on the topic or did it simply
get forgotten?
I found the original message on this ML. As Kai said, the patch looked
reasonable, but it couldn't be applied because it wasn't generated using
`git format-patch` and the original author's email address was
truncated. So would you please provide a formatted patch (and send it as
an attachment if possible). I could plagiarize the patch but good guys
don't do that. :S

The problem has been there half a year [1]. Is this patch OK to apply?

[1] https://sourceforge.net/p/mingw-w64/mailman/message/35294616/

--
Best regards,
LH_Mouse






From 2d36585b035289542975cfba559e193cb2c8d5ec Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Fri, 10 Mar 2017 15:31:32 +0800
Subject: [PATCH] winpthreads/src/thread.c: Force aligning ESP on 16-byte
boundaries on x86. ESP isn't guaranteed to be aligned on 16-byte boundaries if the thread is created with _beginthreadex(), but modern GCC assumes it is and generates code that requires it. For example, the MOVDQA instruction may be used to load XMMWORDs from the stack when SSE2 is enabled, which results
 in segment faults if the address isn't correctly aligned.

Reported-by: Aleksey Vasenev
Reference: https://sourceforge.net/p/mingw-w64/mailman/message/35294616/

Signed-off-by: Liu Hao <[email protected]>
---
 mingw-w64-libraries/winpthreads/src/thread.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c
index 9c79ac9a..f847680d 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1457,6 +1457,12 @@ pthread_setcanceltype (int type, int *oldtype)
   return 0;
 }

+#if defined(__i686__)
+/* Align ESP on 16-byte boundaries. */
+#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+__attribute__((force_align_arg_pointer))
+#  endif
+#endif
 int
 pthread_create_wrapper (void *args)
 {
--
2.12.0


From 2d36585b035289542975cfba559e193cb2c8d5ec Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Fri, 10 Mar 2017 15:31:32 +0800
Subject: [PATCH] winpthreads/src/thread.c: Force aligning ESP on 16-byte
 boundaries on x86. ESP isn't guaranteed to be aligned on 16-byte boundaries
 if the thread is created with _beginthreadex(), but modern GCC assumes it is
 and generates code that requires it. For example, the MOVDQA instruction may
 be used to load XMMWORDs from the stack when SSE2 is enabled, which results
 in segment faults if the address isn't correctly aligned.

Reported-by: Aleksey Vasenev
Reference: https://sourceforge.net/p/mingw-w64/mailman/message/35294616/

Signed-off-by: Liu Hao <[email protected]>
---
 mingw-w64-libraries/winpthreads/src/thread.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index 9c79ac9a..f847680d 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1457,6 +1457,12 @@ pthread_setcanceltype (int type, int *oldtype)
   return 0;
 }
 
+#if defined(__i686__)
+/* Align ESP on 16-byte boundaries. */
+#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+__attribute__((force_align_arg_pointer))
+#  endif
+#endif
 int
 pthread_create_wrapper (void *args)
 {
-- 
2.12.0

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to