Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:18:43+00:00 2026-06-08T13:18:43+00:00

Possible Duplicate: Qt, GCC, SSE and stack alignment I am converting a simulator from

  • 0

Possible Duplicate:
Qt, GCC, SSE and stack alignment

I am converting a simulator from TinyPTC to WxWidgets. Some graphics routines are optimized with SSE intrinsics. During the initialization of the GUI, the initial state is rendered once, and all of the SSE routines work perfectly. However, if I call them later from an event handler, I get a SIGSEGV.

At first I thought those were some weird alignment issues, but it even happens for:

__m128i zero = _mm_setzero_si128();

When I replace the SSE routines with non-optimized code, everything works fine.

I suppose the event handling happens in a different thread than the initialization. Is there anything to watch out for when using SSE from different threads? What else could possibly cause this behavior?


The SIGSEGV happens at a movdqa %xmm0, -40(%ebp) instruction (there are several of those). If I compile with -O1, the movdqa instructions are completely optimized away, and the program runs fine. It seems to be an alignment issue with the stack after all, as already pointed out in the comments.

Here is the command CodeLite generates for compilation:

g++ -c "x:/some/folder/sse.cpp" -g -O1 -Wall -std=gnu++0x -msse3
-mthreads -DHAVE_W32API_H -D__WXMSW__ -D__WXDEBUG__ -D_UNICODE
-ID:\CodeLite\wxWidgets\lib\gcc_dll\mswud -ID:\CodeLite\wxWidgets\include
-DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -o ./Debug/sse.o -I.

Anything unusual? Is it possible that WxWidgets changes the alignment settings somewhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:18:45+00:00Added an answer on June 8, 2026 at 1:18 pm

    Your stack pointer is probably misaligned. The SSE instructions require that all memory locations are 16-byte aligned. The issue isn’t occurring with the _mm_setzero_si128 instruction, which just loads a constant into an SSE register, but rather the instruction that the compiler generated to store that register back into memory on the stack.

    First make sure you’re not using an outdated version of GCC (older versions had issues with stack alignment with SSE). Then, try also adding the -mstackrealign option for that translation unit, which will forcibly realign the stack to 16-byte alignment on function entry (which adds a very tiny runtime cost).

    See Volume 2B page 4-67 of the Intel Architectures Software Developer Manuals for more details on the movdqa instruction and the exact conditions under which it can generate exceptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do you get assembler output from C/C++ source in gcc? Hello
Possible Duplicate: GCC problem : using a member of a base class that depends
Possible Duplicate: problem with template inheritance This code doesn't compile in GCC: template <typename
Possible Duplicate: Should a function have only one return statement? Hello, gcc 4.4.4 c89
Possible Duplicate: Why does gcc have “â” in all its error messages? New to
Possible Duplicate: Creating ELF instead of a.out When I use the command gcc hello.cpp
Possible Duplicate: Get path of executable I'm programming on Windows using MinGW, gcc 4.4.3.
Possible Duplicate: Why can you return from a non-void function without returning a value
Possible Duplicate: How to get current python interpreter path from inside a Python script?
Possible Duplicate: GCC STL bound checking Is there something like a automatic debug version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.