public inbox for
 help / color / mirror / Atom feed
From: "Sébastien Kunz-Jacques" <>
Subject: pthreads-win32 2.8.0, stack alignment, and SSE code
Date: Sun, 05 Oct 2008 12:32:00 -0000	[thread overview]
Message-ID: <> (raw)


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 && 
 #if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined 

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?

             reply	other threads:[~2008-10-05 12:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-05 12:32 Sébastien Kunz-Jacques [this message]
2008-10-05 13:41 ` Ramiro Polla
2008-10-05 14:47   ` Sébastien Kunz-Jacques
2008-10-05 18:27     ` Ramiro Polla
2008-10-05 18:52       ` Sébastien Kunz-Jacques
2008-10-05 19:25         ` Ramiro Polla
2008-10-05 20:12           ` Sébastien Kunz-Jacques
2008-10-05 22:42             ` Ramiro Polla
2008-10-09 13:14               ` Ross Johnson
2008-10-09 19:51                 ` Sébastien Kunz-Jacques
2008-10-23  5:57                 ` Sébastien Kunz-Jacques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).