After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 500833 - [FFT] Struct alignment issues on sparc
[FFT] Struct alignment issues on sparc
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.15
Other Linux
: Normal normal
: 0.10.22
Assigned To: Sebastian Dröge (slomo)
GStreamer Maintainers
: 548193 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-12-01 10:11 UTC by Sebastian Dröge (slomo)
Modified: 2009-01-16 11:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fft-alignment.diff (10.31 KB, patch)
2009-01-13 20:22 UTC, Sebastian Dröge (slomo)
accepted-commit_after_freeze Details | Review

Description Sebastian Dröge (slomo) 2007-12-01 10:11:54 UTC
Hi,
since we enabled to run the unit test suite on the Debian build servers there were some unit test failures on various architectures:

For all architectures the pipelines/theoraenc unit test failed:
Running suite(s): theoraenc
33%: Checks: 3, Failures: 2, Errors: 0
pipelines/theoraenc.c:58:F:general:tf:0: expected duration 0:00:00.100000000, but got duration 0:00:00.200000000
pipelines/theoraenc.c:58:F:general:tf:0: expected duration 0:00:00.100000000, but got duration 0:00:00.200000000
FAIL: pipelines/theoraenc

This is with libtheora 1.0~beta2.

------------------------------------

On powerpc/s390 pipelines/streamheader and elements/gdpdepay failed:

Running suite(s): gdpdepay
66%: Checks: 3, Failures: 1, Errors: 0
elements/gdpdepay.c:372:F:general:tf:0: Assertion 'GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS)' failed
FAIL: elements/gdpdepay

Running suite(s): streamheader
50%: Checks: 2, Failures: 1, Errors: 0
pipelines/streamheader.c:203:F:general:tf:0: 'n_in_caps' (0) is not equal to '3' (3)
FAIL: pipelines/streamheader

this seems to be similar to the core unit test failure on those archs:
Running suite(s): data protocol
80%: Checks: 5, Failures: 1, Errors: 0
libs/gdp.c:150:F:general:tf:0: GST_BUFFER_IN_CAPS flag should have been copied !

which is probably a compiler bug.

------------------------------------

On ia64 libs/cddabasesrc.c failed:

Running suite(s): cddabasesrc
0%: Checks: 2, Failures: 0, Errors: 2
libs/cddabasesrc.c:290:E:general:tf:0: (after this point) Received signal 7 (Bus error)
libs/cddabasesrc.c:323:E:general:tf:0: (after this point) Received signal 7 (Bus error)
FAIL: libs/cddabasesrc

------------------------------------

On hppa libs/fft failed:

Running suite(s): fft library
76%: Checks: 13, Failures: 0, Errors: 3
libs/fft.c:410:E:general:tf:0: (after this point) Received signal 10 (Bus error)
libs/fft.c:448:E:general:tf:0: (after this point) Received signal 10 (Bus error)
libs/fft.c:490:E:general:tf:0: (after this point) Received signal 10 (Bus error)
FAIL: libs/fft



At least the theora failure seems to be a general problem. The other's could be caused by the hardware, compiler, etc too. Needs further investigation.
Comment 1 Sebastian Dröge (slomo) 2007-12-01 16:13:41 UTC
The failure in libs/fft also happens on sparc, the powerpc/s390 one is handled in bug #348114.
Comment 2 Sebastian Dröge (slomo) 2007-12-04 15:18:05 UTC
The theoraenc bug is handled in bug #497964.

So this leaves the sparc/hppa failures on libs/fft and the ia64 failure on libs/cddabasesrc.
Comment 3 Tim-Philipp Müller 2008-01-07 14:20:41 UTC
Do you have access to those machines to investigate?
Comment 4 David Schleef 2008-01-07 22:29:05 UTC
I'd bet those bus errors are loading/storing at an unaligned address.

Also, does check have the ability to dump stack when it gets a segfault/bus error?
Comment 5 Tim-Philipp Müller 2008-01-08 15:58:18 UTC
> I'd bet those bus errors are loading/storing at an unaligned address.
> 
> Also, does check have the ability to dump stack when it gets a segfault/bus
> error?

Don't know if check does, but there's a half-baked patch in bug #404631 that does that.

Comment 6 Sebastian Dröge (slomo) 2008-02-27 10:42:05 UTC
Ok, this fixes libs/cddabasesrc on IA64:

2008-02-27  Sebastian Dröge  <slomo@circular-chaos.org>

	* gst-libs/gst/cdda/sha1.c: (sha_transform):
	Use memcpy() instead of upcasting a byte array to long *. This
	fixes an unaligned memory access, resulting in SIGBUS on IA64.
	This should be ported to GCheckSum once we can use GLib 2.16.
	Partially fixes bug #500833.
Comment 7 Sebastian Dröge (slomo) 2008-02-27 11:36:51 UTC
Ok, for the fft SIGBUS things are more difficult:

First SIGBUS is in
0xf7fb3a70 in kiss_fft_f64_alloc (nfft=1024, inverse_fft=0, mem=0x45af4, 
    lenmem=0xffa6d3ac) at kiss_fft_f64.c:363
363	    for (i = 0; i < nfft; ++i) {

Moving the definition of "pi" to the top of the function body fixes this.


Next problem is:
0xf7f80500 in kf_work (Fout=0x49bfc, f=0x3dac8, fstride=256, in_stride=1, 
    factors=0x45b24, st=0x45af4) at kiss_fft_f64.c:270
270	      *Fout = *f;
(gdb) bt
  • #0 kf_work
    at kiss_fft_f64.c line 270
  • #1 kf_work
    at kiss_fft_f64.c line 275
  • #2 kf_work
    at kiss_fft_f64.c line 275
  • #3 kf_work
    at kiss_fft_f64.c line 275
  • #4 kf_work
    at kiss_fft_f64.c line 275
  • #5 kiss_fft_f64_stride
    at kiss_fft_f64.c line 390
  • #6 kiss_fft_f64
    at kiss_fft_f64.c line 398
  • #7 kiss_fftr_f64
    at kiss_fftr_f64.c line 87
  • #8 test_f64_0hz
    at libs/fft.c line 419




The problem here seems to be the following:
timedata is given as double * to kiss_fftr_f64(), casted to pointer to a struct { double a; double b; } and used as that in the line where it explodes.

I wonder why, the doubles in the array are all properly aligned and both members of the struct should be aligned the same way. Any ideas? :)
Comment 8 Tim-Philipp Müller 2008-04-28 22:35:03 UTC
> 0xf7f80500 in kf_work (Fout=0x49bfc, f=0x3dac8, fstride=256, in_stride=1, 
>     factors=0x45b24, st=0x45af4) at kiss_fft_f64.c:270
> 270           *Fout = *f;
> (gdb) bt
> #0  0xf7f80500 in kf_work (Fout=0x49bfc, f=0x3dac8, fstride=256, in_stride=1, 
>     factors=0x45b24, st=0x45af4) at kiss_fft_f64.c:270
> #1  0xf7f80580 in kf_work (Fout=0x49bfc, f=0x3dac8, fstride=64, in_stride=1, 
>     factors=0x45b1c, st=0x45af4) at kiss_fft_f64.c:275
> ...
> 
> I wonder why, the doubles in the array are all properly aligned and both
> members of the struct should be aligned the same way. Any ideas? :)

Isn't Fout supposed to be properly aligned (to multiples of 8?) too?

Comment 9 Sebastian Dröge (slomo) 2008-05-05 06:47:40 UTC
Yes, it is... thanks for spotting :) Now let's find the cause...
Comment 10 Sebastian Dröge (slomo) 2008-05-05 07:27:02 UTC
Aligning it to 8, 16 or even 32 bytes doesn't make a difference... unfortunately I currently can't get a new backtrace because gdb on that machine simply hangs when starting the test case :/
Comment 11 Sebastian Dröge (slomo) 2008-08-18 09:15:36 UTC
*** Bug 548193 has been marked as a duplicate of this bug. ***
Comment 12 Sebastian Dröge (slomo) 2009-01-13 20:22:34 UTC
Created attachment 126373 [details] [review]
fft-alignment.diff

Possible patch for the FFT SIGBUS on sparc... I'll test it later on sparc ;)
Comment 13 Sebastian Dröge (slomo) 2009-01-14 07:27:02 UTC
Yes, this patch fixes the SIGBUS on sparc :)
Comment 14 Sebastian Dröge (slomo) 2009-01-16 11:43:45 UTC
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.