Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Weird code generation: (3 Items)
   
Weird code generation  
I`ve rebuild all  project with 4.4.2 (6.5.0) and one of our program is doing a SIGSEGV.  I traced the problem to the 
following code (simplified)

int map[256];
for ( int i=0; i<256;++i)
  map[i];

Seems simple enough right?   The compiler optimisizes this code to use xmm0 register to fill out the map array.  The 
xxm0 register being16 bytes the loop is 4 time shorter. That makes sense.  The problem with this is for the instruction 
 moveaps xmm0,(%eax) to work  eax must point to a 16 bytes aligned memory adress, and it's not.... That is what causes 
the SIGSEGV.  

Looking at the assembly code, there is nothing that check if the data is align.  The fonction assumes, upon entry, that 
the stack is already 16-byte aligned.  

Note that the crash appears in thread 3, the same fonction called from thread 1 is not causing any issue.

What did I miss?
Re: Weird code generation  
I forgot to mentionned this code is in a .so.
Re: Weird code generation  
I added -mstackrealign to the makefile responsible for creating the shared object.  That doesn't make me feel safe...