Opened 17 years ago
Closed 17 years ago
#6535 closed patch (fixed)
Soundtouch crashes in sse_gcc.cpp due to unaligned variable
| Reported by: | Owned by: | danielk | |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.22 |
| Component: | MythTV - General | Version: | head |
| Severity: | medium | Keywords: | soundtouch sse |
| Cc: | Ticket locked: | no |
Description
calcCrossCorrMulti and calcCrossCorrStereo use movdqa, which requires 16-byte alignment, but variable "out" is declared as dynamic unaligned. This patch redefines "out" as global static aligned(16). Global because gcc versions <4.4 reportedly fail to align dynamic variables properly. Tested on x86_32 with gcc 4.2.4
Attachments (2)
Change History (9)
by , 17 years ago
| Attachment: | sse_gcc.patch added |
|---|
comment:1 by , 17 years ago
| Status: | new → infoneeded_new |
|---|
comment:2 by , 17 years ago
GCC bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660 Comment 14 indicates gcc 4.4 revision 138335 fixes dynamic alignment > required alignment. I'll try your suggested workaround.
follow-up: 4 comment:3 by , 17 years ago
Revised the patch using Daniel's workaround. I tried attribute((aligned(8))) to make x smaller, but gcc then incorrectly calculated (int*)out. I believe this is the behavior described in comment 5 of the gcc bugzilla.
comment:4 by , 17 years ago
To clarify my last comment, the revised patch (which doesn't use the aligned attribute) works and was tested against gcc 4.2.4. Debugging showed proper data alignment and pointer calculation.
comment:5 by , 17 years ago
| Status: | infoneeded_new → new |
|---|
comment:6 by , 17 years ago
| Milestone: | unknown → 0.22 |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |

Jeff, a global is no good. Please create a larger variable on the stack yourself and align a pointer into it and call it out. Something like "int x[16+4]; int *out=((&x+15)&~0xf);" but of course tested. Also a comment should reference the gcc bug report # for the fix, or at least the version it was fixed in.
PS I believe all versions of gcc actually do successfully give you 8 byte alignment; you could use that to make x smaller...