Red Hat Bugzilla – Bug 447132
gcc 4.3.0 generates movdqa instructions to non-aligned memory causing crash
Last modified: 2009-07-14 13:56:46 EDT
Description of problem:
GCC 4.3.0 generates movdqa instructions referencing non-aligned memory when
optimizing with "-O3 -march=core2". The documentation for movdqa says that the
mmemory location must be 16-byte aligned, but GCC is only aligning to 8 bytes.
The improperly aligned memory location causes a crash.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Build Firefox 3 trunk with "-O3 -march=core2". The pow5mult routine in jsdtoa.c
will be have the bad movdqa instructions, and Firefox will crash on startup.
Could ensure that memory is properly aligned or could use the movdqu instruction
which does not require alignment
The assembly in question looks like:
movdqa %xmm0, -200(%ebp)
movl p5s_lock@GOTOFF(%ebx), %eax
movl %eax, (%esp)
movl -28(%ebp), %esi
movdqa -200(%ebp), %xmm0
It looks like the compiler is trying to preserve the value of %xmm0 across
function calls. The offset used by all the examples of this is -200, which is
not 16-byte aligned.
I should also note that I am running x86 F9.
Then likely firefox is buggy. -200(%ebp) must be 16-byte aligned. The ABI
says that %esp should be 16-byte aligned right before the call instruction is
executed (i.e. first argument passed on the stack is 16-byte aligned).
But the call instruction pushes 4 bytes (the return address) and in the function
movl %esp, %ebp
another 4 bytes are pushed. So, for functions that use frame pointer %ebp
is supposed to satisfy ((%ebp + 8) & 15) == 0. Therefore, %ebp - 200 is also
16-byte aligned. AFAIK Firefox contains bridges written in assembly, so that's
most likely the place which doesn't honor the ABI and misaligns the stack. To
my knowledge all similar issues on the glibc side (e.g. in clone/pthread_create,
or makecontext, have been fixed quite some time ago).
Should be fairly easy to find out, run it in the debugger, see where the
misaligned access is done, and go up through the backtrace, checking whether the
stack pointer is aligned properly in each frame, in some lower frames it will be
most likely misaligned, in start_thread or main it should be aligned properly.
Until that is fixed in firefox, you just can't build firefox with the vectorizer
on (enabled at -O3 plus CPU selection for SSE/SSE2 support). OT, -O3 is really
meant to be used for performance critical code, if you build a huge app like
firefox with -O3, you'll see most likely performance degradation due to much
increased cache footprint.
This message is a reminder that Fedora 9 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 9. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora
'version' of '9'.
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version prior to Fedora 9's end of life.
Bug Reporter: Thank you for reporting this issue and we are sorry that
we may not be able to fix it before Fedora 9 is end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora please change the 'version' of this
bug to the applicable version. If you are unable to change the version,
please add a comment here and someone will do it for you.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
The process we are following is described here:
Fedora 9 changed to end-of-life (EOL) status on 2009-07-10. Fedora 9 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version.
Thank you for reporting this bug and we are sorry it could not be fixed.