public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48659] New: Segmentation fault when using openMP and SSE
@ 2011-04-18  6:59 npozar at quick dot cz
  2011-04-18 12:22 ` [Bug c++/48659] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: npozar at quick dot cz @ 2011-04-18  6:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659

           Summary: Segmentation fault when using openMP and SSE
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: npozar@quick.cz


Created attachment 24026
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24026
A code snippet that reproduces the error

g++ tries to save an xmm register using MOVAPD (SSE instruction) to the stack
when switching between working chunks during openMP multithreading. This
obviously causes a random segmentation fault when the stack pointer happens not
be aligned to a 16-byte boundary. 

Please see the attached code. I compile it with g++ 4.5.2 (I'm using MinGW) and
flags -O3 -msse3 -fopenmp.

It is important that the optimization is on and the compiler tries to save the
xmm register containing the constant zero between working chunks. This is the
instruction that causes the segmentation fault if ebp-0x48 is not divisible by
0x10:

0040143a:   movapd %xmm1,-0x48(%ebp) // right here
0040143f:   call 0x4014bc <GOMP_loop_dynamic_next>



PS. I have to admit that I'm completely new to GCC, openMP or SSE (I just
learned about openMP today and I've playing with them for a couple hours only),
so I might be just doing something really stupid.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/48659] Segmentation fault when using openMP and SSE
  2011-04-18  6:59 [Bug c++/48659] New: Segmentation fault when using openMP and SSE npozar at quick dot cz
@ 2011-04-18 12:22 ` rguenth at gcc dot gnu.org
  2013-01-26 14:04 ` [Bug target/48659] " redi at gcc dot gnu.org
  2013-01-28 11:53 ` daniel.f.starke at freenet dot de
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-18 12:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-18 12:17:12 UTC ---
On linux we assume a 16 byte aligned stack for threads, so this might hint
at some MinGW specific issue either in our OMP runtime or with windows
thread handling.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/48659] Segmentation fault when using openMP and SSE
  2011-04-18  6:59 [Bug c++/48659] New: Segmentation fault when using openMP and SSE npozar at quick dot cz
  2011-04-18 12:22 ` [Bug c++/48659] " rguenth at gcc dot gnu.org
@ 2013-01-26 14:04 ` redi at gcc dot gnu.org
  2013-01-28 11:53 ` daniel.f.starke at freenet dot de
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-26 14:04 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-26 14:03:44 UTC ---
Kai, is this reproducable with current releases, and can you confirm Richard's
suggestion about threads not having 16-byte aligned stacks?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/48659] Segmentation fault when using openMP and SSE
  2011-04-18  6:59 [Bug c++/48659] New: Segmentation fault when using openMP and SSE npozar at quick dot cz
  2011-04-18 12:22 ` [Bug c++/48659] " rguenth at gcc dot gnu.org
  2013-01-26 14:04 ` [Bug target/48659] " redi at gcc dot gnu.org
@ 2013-01-28 11:53 ` daniel.f.starke at freenet dot de
  2 siblings, 0 replies; 4+ messages in thread
From: daniel.f.starke at freenet dot de @ 2013-01-28 11:53 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659

--- Comment #3 from Daniel Starke <daniel.f.starke at freenet dot de> 2013-01-28 11:53:14 UTC ---
I can confirm this bug for gcc 4.7.2 mingw64. The -mstackrealign command-line
flag can be used as workaround as described on
http://stackoverflow.com/questions/6716654/segmentation-fault-using-openmp-and-sse
until this bug is properly patched.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-28 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-18  6:59 [Bug c++/48659] New: Segmentation fault when using openMP and SSE npozar at quick dot cz
2011-04-18 12:22 ` [Bug c++/48659] " rguenth at gcc dot gnu.org
2013-01-26 14:04 ` [Bug target/48659] " redi at gcc dot gnu.org
2013-01-28 11:53 ` daniel.f.starke at freenet dot de

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).