mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-04 16:39:39 +00:00
gst-libs/gst/fft/: Use correct struct alignment everywhere to prevent unaligned memory accesses, resulting in SIGBUS ...
Original commit message from CVS: * gst-libs/gst/fft/_kiss_fft_guts_f32.h: * gst-libs/gst/fft/_kiss_fft_guts_f64.h: * gst-libs/gst/fft/_kiss_fft_guts_s16.h: * gst-libs/gst/fft/_kiss_fft_guts_s32.h: * gst-libs/gst/fft/kiss_fftr_f32.c: (kiss_fftr_f32_alloc): * gst-libs/gst/fft/kiss_fftr_f64.c: (kiss_fftr_f64_alloc): * gst-libs/gst/fft/kiss_fftr_s16.c: (kiss_fftr_s16_alloc): * gst-libs/gst/fft/kiss_fftr_s32.c: (kiss_fftr_s32_alloc): Use correct struct alignment everywhere to prevent unaligned memory accesses, resulting in SIGBUS on sparc and probably others. Fixes bug #500833.
This commit is contained in:
parent
98ea758763
commit
4d3ff205be
9 changed files with 93 additions and 20 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2009-01-16 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
|
||||
* gst-libs/gst/fft/_kiss_fft_guts_f32.h:
|
||||
* gst-libs/gst/fft/_kiss_fft_guts_f64.h:
|
||||
* gst-libs/gst/fft/_kiss_fft_guts_s16.h:
|
||||
* gst-libs/gst/fft/_kiss_fft_guts_s32.h:
|
||||
* gst-libs/gst/fft/kiss_fftr_f32.c: (kiss_fftr_f32_alloc):
|
||||
* gst-libs/gst/fft/kiss_fftr_f64.c: (kiss_fftr_f64_alloc):
|
||||
* gst-libs/gst/fft/kiss_fftr_s16.c: (kiss_fftr_s16_alloc):
|
||||
* gst-libs/gst/fft/kiss_fftr_s32.c: (kiss_fftr_s32_alloc):
|
||||
Use correct struct alignment everywhere to prevent unaligned
|
||||
memory accesses, resulting in SIGBUS on sparc and probably others.
|
||||
Fixes bug #500833.
|
||||
|
||||
2009-01-16 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
|
||||
* gst-libs/gst/tag/gsttagdemux.c: (gst_tag_demux_srcpad_event):
|
||||
|
|
|
@ -19,6 +19,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
#include "kiss_fft_f32.h"
|
||||
#include <limits.h>
|
||||
|
||||
/* The 2*sizeof(size_t) alignment here is borrowed from
|
||||
* GNU libc, so it should be good most everywhere.
|
||||
* It is more conservative than is needed on some 64-bit
|
||||
* platforms, but ia64 does require a 16-byte alignment.
|
||||
* The SIMD extensions for x86 and ppc32 would want a
|
||||
* larger alignment than this, but we don't need to
|
||||
* do better than malloc.
|
||||
*
|
||||
* Borrowed from GLib's gobject/gtype.c
|
||||
*/
|
||||
#define STRUCT_ALIGNMENT (2 * sizeof (size_t))
|
||||
#define ALIGN_STRUCT(offset) \
|
||||
((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
|
|
|
@ -19,6 +19,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
#include "kiss_fft_f64.h"
|
||||
#include <limits.h>
|
||||
|
||||
/* The 2*sizeof(size_t) alignment here is borrowed from
|
||||
* GNU libc, so it should be good most everywhere.
|
||||
* It is more conservative than is needed on some 64-bit
|
||||
* platforms, but ia64 does require a 16-byte alignment.
|
||||
* The SIMD extensions for x86 and ppc32 would want a
|
||||
* larger alignment than this, but we don't need to
|
||||
* do better than malloc.
|
||||
*
|
||||
* Borrowed from GLib's gobject/gtype.c
|
||||
*/
|
||||
#define STRUCT_ALIGNMENT (2 * sizeof (size_t))
|
||||
#define ALIGN_STRUCT(offset) \
|
||||
((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
|
|
|
@ -19,6 +19,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
#include "kiss_fft_s16.h"
|
||||
#include <limits.h>
|
||||
|
||||
/* The 2*sizeof(size_t) alignment here is borrowed from
|
||||
* GNU libc, so it should be good most everywhere.
|
||||
* It is more conservative than is needed on some 64-bit
|
||||
* platforms, but ia64 does require a 16-byte alignment.
|
||||
* The SIMD extensions for x86 and ppc32 would want a
|
||||
* larger alignment than this, but we don't need to
|
||||
* do better than malloc.
|
||||
*
|
||||
* Borrowed from GLib's gobject/gtype.c
|
||||
*/
|
||||
#define STRUCT_ALIGNMENT (2 * sizeof (size_t))
|
||||
#define ALIGN_STRUCT(offset) \
|
||||
((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
|
|
|
@ -19,6 +19,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
#include "kiss_fft_s32.h"
|
||||
#include <limits.h>
|
||||
|
||||
/* The 2*sizeof(size_t) alignment here is borrowed from
|
||||
* GNU libc, so it should be good most everywhere.
|
||||
* It is more conservative than is needed on some 64-bit
|
||||
* platforms, but ia64 does require a 16-byte alignment.
|
||||
* The SIMD extensions for x86 and ppc32 would want a
|
||||
* larger alignment than this, but we don't need to
|
||||
* do better than malloc.
|
||||
*
|
||||
* Borrowed from GLib's gobject/gtype.c
|
||||
*/
|
||||
#define STRUCT_ALIGNMENT (2 * sizeof (size_t))
|
||||
#define ALIGN_STRUCT(offset) \
|
||||
((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
|
|
|
@ -39,9 +39,8 @@ kiss_fftr_f32_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
nfft >>= 1;
|
||||
|
||||
kiss_fft_f32_alloc (nfft, inverse_fft, NULL, &subsize);
|
||||
memneeded =
|
||||
sizeof (struct kiss_fftr_f32_state) + subsize +
|
||||
sizeof (kiss_fft_f32_cpx) * (nfft * 2);
|
||||
memneeded = ALIGN_STRUCT (sizeof (struct kiss_fftr_f32_state))
|
||||
+ ALIGN_STRUCT (subsize) + sizeof (kiss_fft_f32_cpx) * (nfft * 2);
|
||||
|
||||
if (lenmem == NULL) {
|
||||
st = (kiss_fftr_f32_cfg) KISS_FFT_F32_MALLOC (memneeded);
|
||||
|
@ -53,8 +52,9 @@ kiss_fftr_f32_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
if (!st)
|
||||
return NULL;
|
||||
|
||||
st->substate = (kiss_fft_f32_cfg) (st + 1); /*just beyond kiss_fftr_f32_state struct */
|
||||
st->tmpbuf = (kiss_fft_f32_cpx *) (((char *) st->substate) + subsize);
|
||||
st->substate = (kiss_fft_f32_cfg) (((char *) st) + ALIGN_STRUCT (sizeof (struct kiss_fftr_f32_state))); /*just beyond kiss_fftr_f32_state struct */
|
||||
st->tmpbuf =
|
||||
(kiss_fft_f32_cpx *) (((char *) st->substate) + ALIGN_STRUCT (subsize));
|
||||
st->super_twiddles = st->tmpbuf + nfft;
|
||||
kiss_fft_f32_alloc (nfft, inverse_fft, st->substate, &subsize);
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ kiss_fftr_f64_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
nfft >>= 1;
|
||||
|
||||
kiss_fft_f64_alloc (nfft, inverse_fft, NULL, &subsize);
|
||||
memneeded =
|
||||
sizeof (struct kiss_fftr_f64_state) + subsize +
|
||||
sizeof (kiss_fft_f64_cpx) * (nfft * 2);
|
||||
memneeded = ALIGN_STRUCT (sizeof (struct kiss_fftr_f64_state))
|
||||
+ ALIGN_STRUCT (subsize)
|
||||
+ sizeof (kiss_fft_f64_cpx) * (nfft * 2);
|
||||
|
||||
if (lenmem == NULL) {
|
||||
st = (kiss_fftr_f64_cfg) KISS_FFT_F64_MALLOC (memneeded);
|
||||
|
@ -53,8 +53,9 @@ kiss_fftr_f64_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
if (!st)
|
||||
return NULL;
|
||||
|
||||
st->substate = (kiss_fft_f64_cfg) (st + 1); /*just beyond kiss_fftr_f64_state struct */
|
||||
st->tmpbuf = (kiss_fft_f64_cpx *) (((char *) st->substate) + subsize);
|
||||
st->substate = (kiss_fft_f64_cfg) (((char *) st) + ALIGN_STRUCT (sizeof (struct kiss_fftr_f64_state))); /*just beyond kiss_fftr_f64_state struct */
|
||||
st->tmpbuf =
|
||||
(kiss_fft_f64_cpx *) (((char *) st->substate) + ALIGN_STRUCT (subsize));
|
||||
st->super_twiddles = st->tmpbuf + nfft;
|
||||
kiss_fft_f64_alloc (nfft, inverse_fft, st->substate, &subsize);
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ kiss_fftr_s16_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
nfft >>= 1;
|
||||
|
||||
kiss_fft_s16_alloc (nfft, inverse_fft, NULL, &subsize);
|
||||
memneeded =
|
||||
sizeof (struct kiss_fftr_s16_state) + subsize +
|
||||
sizeof (kiss_fft_s16_cpx) * (nfft * 2);
|
||||
memneeded = ALIGN_STRUCT (sizeof (struct kiss_fftr_s16_state))
|
||||
+ ALIGN_STRUCT (subsize)
|
||||
+ sizeof (kiss_fft_s16_cpx) * (nfft * 2);
|
||||
|
||||
if (lenmem == NULL) {
|
||||
st = (kiss_fftr_s16_cfg) KISS_FFT_S16_MALLOC (memneeded);
|
||||
|
@ -53,8 +53,9 @@ kiss_fftr_s16_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
if (!st)
|
||||
return NULL;
|
||||
|
||||
st->substate = (kiss_fft_s16_cfg) (st + 1); /*just beyond kiss_fftr_s16_state struct */
|
||||
st->tmpbuf = (kiss_fft_s16_cpx *) (((char *) st->substate) + subsize);
|
||||
st->substate = (kiss_fft_s16_cfg) (((char *) st) + ALIGN_STRUCT (sizeof (struct kiss_fftr_s16_state))); /*just beyond kiss_fftr_s16_state struct */
|
||||
st->tmpbuf =
|
||||
(kiss_fft_s16_cpx *) (((char *) st->substate) + ALIGN_STRUCT (subsize));
|
||||
st->super_twiddles = st->tmpbuf + nfft;
|
||||
kiss_fft_s16_alloc (nfft, inverse_fft, st->substate, &subsize);
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ kiss_fftr_s32_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
nfft >>= 1;
|
||||
|
||||
kiss_fft_s32_alloc (nfft, inverse_fft, NULL, &subsize);
|
||||
memneeded =
|
||||
sizeof (struct kiss_fftr_s32_state) + subsize +
|
||||
sizeof (kiss_fft_s32_cpx) * (nfft * 2);
|
||||
memneeded = ALIGN_STRUCT (sizeof (struct kiss_fftr_s32_state))
|
||||
+ ALIGN_STRUCT (subsize)
|
||||
+ sizeof (kiss_fft_s32_cpx) * (nfft * 2);
|
||||
|
||||
if (lenmem == NULL) {
|
||||
st = (kiss_fftr_s32_cfg) KISS_FFT_S32_MALLOC (memneeded);
|
||||
|
@ -53,8 +53,9 @@ kiss_fftr_s32_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
|
|||
if (!st)
|
||||
return NULL;
|
||||
|
||||
st->substate = (kiss_fft_s32_cfg) (st + 1); /*just beyond kiss_fftr_s32_state struct */
|
||||
st->tmpbuf = (kiss_fft_s32_cpx *) (((char *) st->substate) + subsize);
|
||||
st->substate = (kiss_fft_s32_cfg) (((char *) st) + ALIGN_STRUCT (sizeof (struct kiss_fftr_s32_state))); /*just beyond kiss_fftr_s32_state struct */
|
||||
st->tmpbuf =
|
||||
(kiss_fft_s32_cpx *) (((char *) st->substate) + ALIGN_STRUCT (subsize));
|
||||
st->super_twiddles = st->tmpbuf + nfft;
|
||||
kiss_fft_s32_alloc (nfft, inverse_fft, st->substate, &subsize);
|
||||
|
||||
|
|
Loading…
Reference in a new issue