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

ivorbisfile_example.c triggers alignment error on armel



Package: libvorbisidec-dev

On armel, when i build ivorbisfile_example.c against the stock
libvorbisidec package, it triggers a series of CPU alignment faults, and
consequently produces bad data.

Interestingly, this seems to be because gcc is happy to align an array
of chars on an odd address under armel (on i386, gcc appears to always
place char arrays on 4-byte boundaries).

since ov_read asks for a char* buffer, but then casts it to shorts, if
the char* buffer is not short-aligned, the CPU sees an alignment fault.

What the CPU does in the case of an alignment fault is configurable by
echoing the decimal representation of a bitmask into /proc/cpu/alignment:

 1 -> warn
 2 -> fixup (software workaround to correct the alignment error)
 4 -> signal (send a SIGBUS to the child process)

What to do on a user fault defaults to 0 (none of the above), but if you
set it to 4 or 5, the process will receive a SIGBUS.

with the alignment user fault set to 0, the ivorbisfile_example.c simply
produces bad data.

I reported a few things that should probably be fixed to upstream, and
have a new version of the debian package ready which fixes the example
to work properly;  i'll upload that version shortly.

further reference:

I originally documented the problem upstream in april:

 http://lists.xiph.org/pipermail/tremor/2009-April/001564.html

and followed up again earlier this month (the proposed fixes follow this
thread):

  http://lists.xiph.org/pipermail/tremor/2009-September/001587.html

Martin Guy pointed me in the right direction on
http://bugs.debian.org/547525

	--dkg

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: