This is the mail archive of the mailing list for the pthreas-win32 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pthreads-win32 2.8.0, stack alignment, and SSE code


I encountered problems with SSE code compiled with recent mingw GCC (4.3.2, TDM release, and using pthreads 2.8.0. After inverstigation, crashes occured because the code was trying to read operands on the stack, assuming the stack was 16-byte aligned as is the case in the main thread (the main function aligns the stack and alignment is maintained during each function call). I solved the issue with a very simple patch that uses some GCC wizardry to force stack realignment upon entry in a new thread:

--- ptw32_threadStart.c    Sun May 15 17:28:27 2005
+++ ptw32_threadStart.c    Mon Sep 29 21:28:16 2008
@@ -116,6 +116,9 @@


+#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1)
#if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__))

The attribute force_align_arg_pointer should be added to every function that is called with a stack with insufficient alignment; as far as I am concerned doing this for threadStart only solved my problems. Maybe this small patch could be added to the pthread code?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]