[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#942746: libsoxr: Testsuite crashes on spar64 due to unaligned access in soxr_output_no_callback

Source: libsoxr
Version: 0.1.3-1
Severity: normal
Tags: upstream
User: debian-sparc@lists.debian.org
Usertags: sparc64


The testsuite of libsoxr crashes on sparc64 with "Bus Error" which indicates
an unaligned access in the C code:

 8/10 Test  #8: 28-bit-perfect-65537-44100 .......***Failed    0.23 sec
      Start  9: 1-delay-clear
 9/10 Test  #9: 1-delay-clear ....................Bus error***Exception:   0.05 sec
      Start 10: lsr-bindings

Building the code in debug mode with "./go debug" and running the test manually
in gdb, gives:

glaubitz@kyoto:~/soxr-code$ gdb ./debug/tests/1-delay-clear        
GNU gdb (Debian 8.3.1-1) 8.3.1
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./debug/tests/1-delay-clear...
(gdb) r
Starting program: /home/glaubitz/soxr-code/debug/tests/1-delay-clear 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/sparc64-linux-gnu/libthread_db.so.1".
 9599  4410     0
    0   729  3681

Program received signal SIGBUS, Bus error.
0xffff80010012c7d4 in soxr_output_no_callback (p=0x10000104280, out=0x7feffff4f3c, len=100) at /home/glaubitz/soxr-code/src/soxr.c:689
689         done = soxr_output_1ch(p, u, ((soxr_bufs_t)out)[u], len, separated);
(gdb) bt
#0  0xffff80010012c7d4 in soxr_output_no_callback (p=0x10000104280, out=0x7feffff4f3c, len=100) at /home/glaubitz/soxr-code/src/soxr.c:689
#1  0xffff80010012ca48 in soxr_output (p=0x10000104280, out=0x7feffff4f3c, len0=100) at /home/glaubitz/soxr-code/src/soxr.c:710
#2  0xffff80010012cfc4 in soxr_process (p=0x10000104280, in=0x0, ilen0=0, idone0=0x0, out=0x7feffff4f3c, olen=100, odone0=0x7fefffff0a8) at /home/glaubitz/soxr-code/src/soxr.c:800
#3  0x000001000000120c in main (argc=1, arg=0x7fefffff4b8) at /home/glaubitz/soxr-code/tests/1-delay-clear.c:48

And, indeed, the function soxr_output_no_callback() in src/soxr.c contains
two cases of really poor pointer gymnastics which provoke an unaligned
access which results in poor performance on most architectures or even
crashes like on sparc64.

The problematic part of the code is most likely the "(soxr_bufs_t)out)[u]" part
in line 689 as well as the (soxr_bufs_t)out)[i] in line 683. I have not fully
understood the code yet to come up with a patch, but in most cases a memcpy()
will help to transfer the bytes in question. But maybe someone has a better
suggestion while I try to whip up a patch.


 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply to: