Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-03-13 Thread Aleksey Vasenev

reply to Liu Hao  - 2017-03-08 03:27:18

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

--
Best regards,
LH_Mouse

From 4a86fd92f0fa3322a20e1b6df325e368bfabfaa0 Mon Sep 17 00:00:00 2001
From: Aleksey Vasenev 
Date: Thu, 28 Jul 2016 15:31:06 +0300
Subject: [PATCH] Align thread entry point stack

__attribute__((aligned)) don't work for stack variables in threads created
with _beginthreadex without alignment.

Signed-off-by: Aleksey Vasenev 
---
 mingw-w64-libraries/winpthreads/src/thread.c | 3 +++
 1 file changed, 3 insertions(+)

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

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-03-13 Thread Liu Hao
On 2017/3/10 15:41, Liu Hao wrote:
> 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/
Pushed to master. Please update winpthreads-git.

-- 
Best regards,
LH_Mouse


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-03-09 Thread Liu Hao

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 
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 
---
 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 
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 
---
 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
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-03-07 Thread Liu Hao
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

-- 
Best regards,
LH_Mouse


--
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
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-03-07 Thread Mateusz Mikuła
Forwarding Aleksey's message from MSYS2 discussion:

@mati865  Sorry for long reply. I email
directly to Kai 22 aug 2016:
"Yes i test patch. Patch fix crash: ffmpeg -f lavfi -i testsrc -vcodec
libvpx -threads 2 -f null -
problem discuss: https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2236
Similar patch already integrated in libvpx. libvpx has integrated thread
support together with phtreads.
https://chromium-review.googlesource.com/#/c/364140/;


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?
>



signature.asc
Description: OpenPGP digital signature
--
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
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2017-01-22 Thread Adrien Nader
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?

-- 
Adrien Nader

On Mon, Aug 22, 2016, Kai Tietz wrote:
> Hello Aleksey,
> 
> 2016-08-22 13:52 GMT+02:00 Aleksey Vasenev :
> > __attribute__((aligned)) don't work for stack variables in threads created
> > with _beginthreadex without alignment.
> >
> > Signed-off-by: Aleksey Vasenev 
> > ---
> > send it again
> > github: https://github.com/Ratio2/mingw-w64/tree/align
> > fix crash: ffmpeg -f lavfi -i testsrc -vcodec libvpx -threads 2 -f null -
> > problem discuss: https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2236
> >
> > _beginthreadex does not align the stack on 16-byte boundary as expected
> > by gcc.
> >
> > On x86 targets, the force_align_arg_pointer attribute may be applied to
> > individual function definitions, generating an alternate prologue and
> > epilogue that realigns the run-time stack if necessary. This supports
> > mixing legacy codes that run with a 4-byte aligned stack with modern
> > codes that keep a 16-byte stack for SSE compatibility.
> > https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html
> >
> >  mingw-w64-libraries/winpthreads/src/thread.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
> > b/mingw-w64-libraries/winpthreads/src/thread.c
> > index 565ea48..c771daf 100644
> > --- a/mingw-w64-libraries/winpthreads/src/thread.c
> > +++ b/mingw-w64-libraries/winpthreads/src/thread.c
> > @@ -1454,6 +1454,9 @@ pthread_setcanceltype (int type, int *oldtype)
> >return 0;
> >  }
> >
> > +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
> > +__attribute__((force_align_arg_pointer))
> > +#endif
> >  int
> >  pthread_create_wrapper (void *args)
> >  {
> > --
> > 2.9.1
> 
> I guess you have tested your suggested patch?  Over all it looks
> reasonable to me.
> 
> Regards,
> Kai
> 
> --
> ___
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] Align thread entry point stack

2016-08-22 Thread Kai Tietz
Hello Aleksey,

2016-08-22 13:52 GMT+02:00 Aleksey Vasenev :
> __attribute__((aligned)) don't work for stack variables in threads created
> with _beginthreadex without alignment.
>
> Signed-off-by: Aleksey Vasenev 
> ---
> send it again
> github: https://github.com/Ratio2/mingw-w64/tree/align
> fix crash: ffmpeg -f lavfi -i testsrc -vcodec libvpx -threads 2 -f null -
> problem discuss: https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2236
>
> _beginthreadex does not align the stack on 16-byte boundary as expected
> by gcc.
>
> On x86 targets, the force_align_arg_pointer attribute may be applied to
> individual function definitions, generating an alternate prologue and
> epilogue that realigns the run-time stack if necessary. This supports
> mixing legacy codes that run with a 4-byte aligned stack with modern
> codes that keep a 16-byte stack for SSE compatibility.
> https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html
>
>  mingw-w64-libraries/winpthreads/src/thread.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
> b/mingw-w64-libraries/winpthreads/src/thread.c
> index 565ea48..c771daf 100644
> --- a/mingw-w64-libraries/winpthreads/src/thread.c
> +++ b/mingw-w64-libraries/winpthreads/src/thread.c
> @@ -1454,6 +1454,9 @@ pthread_setcanceltype (int type, int *oldtype)
>return 0;
>  }
>
> +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
> +__attribute__((force_align_arg_pointer))
> +#endif
>  int
>  pthread_create_wrapper (void *args)
>  {
> --
> 2.9.1

I guess you have tested your suggested patch?  Over all it looks
reasonable to me.

Regards,
Kai

--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] Align thread entry point stack

2016-08-22 Thread Aleksey Vasenev
__attribute__((aligned)) don't work for stack variables in threads created
with _beginthreadex without alignment.

Signed-off-by: Aleksey Vasenev 
---
send it again
github: https://github.com/Ratio2/mingw-w64/tree/align
fix crash: ffmpeg -f lavfi -i testsrc -vcodec libvpx -threads 2 -f null -
problem discuss: https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2236

_beginthreadex does not align the stack on 16-byte boundary as expected
by gcc.

On x86 targets, the force_align_arg_pointer attribute may be applied to
individual function definitions, generating an alternate prologue and
epilogue that realigns the run-time stack if necessary. This supports
mixing legacy codes that run with a 4-byte aligned stack with modern
codes that keep a 16-byte stack for SSE compatibility.
https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html

 mingw-w64-libraries/winpthreads/src/thread.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index 565ea48..c771daf 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1454,6 +1454,9 @@ pthread_setcanceltype (int type, int *oldtype)
   return 0;
 }
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+__attribute__((force_align_arg_pointer))
+#endif
 int
 pthread_create_wrapper (void *args)
 {
-- 
2.9.1


--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] Align thread entry point stack

2016-08-01 Thread Aleksey Vasenev
__attribute__((aligned)) don't work for stack variables in threads created
with _beginthreadex without alignment.

Signed-off-by: Aleksey Vasenev 
---
 mingw-w64-libraries/winpthreads/src/thread.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index ceea98e..9fa773a 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1454,6 +1454,9 @@ pthread_setcanceltype (int type, int *oldtype)
   return 0;
 }
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+__attribute__((force_align_arg_pointer))
+#endif
 int
 pthread_create_wrapper (void *args)
 {
-- 
2.9.1


--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public