Opened 15 years ago
Closed 15 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)
Changed 15 years ago by
Attachment: | sse_gcc.patch added |
---|
comment:1 Changed 15 years ago by
Status: | new → infoneeded_new |
---|
comment:2 Changed 15 years ago by
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.
comment:3 follow-up: 4 Changed 15 years ago by
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 Changed 15 years ago by
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 Changed 15 years ago by
Status: | infoneeded_new → new |
---|
comment:6 Changed 15 years ago by
Milestone: | unknown → 0.22 |
---|---|
Owner: | changed from Isaac Richards to danielk |
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...