Bug#822848: mpd FTBFS on Alpha; misaligned arrays in the test suite

Source: mpd
Version: 0.19.14-2
Severity: important
Justification: fails to build form source (but built in the past)
Tags: patch
User: debian-alpha@lists.debian.org
Usertags: alpha

mpd FTBFS on Alpha with a failure in the test suite [1]:

FAIL: test/test_byte_reverse
============================

.F...

!!!FAILURES!!!
Test Results:
Run:  4   Failures: 1   Errors: 0

1) test: ByteReverseTest::TestByteReverse2 (F) line: 58 test/test_byte_reverse.cxx
assertion failed
- Expression: strcmp(result, (const char *)dest) == 0

This occurs because the test suite (in test/test_byte_reversal.cxx)
allocates static char arrays and passes the char arrays to functions
whose respective arguments were declared to be uint16_t *, etc., in
the main code.

This is in the realm of undefined behaviour on architectures with
strict memory alignment requirements.  Although the test only fails
on Alpha (because Alpha has a particular CPU load instruction that
gcc likes to use to add bugs ..., ahem,  optimise the code on the
assumption of alignment) it is potentially a latent bug for other
architectures with strict alignment requirements.

Since the code is compiled with the c++11 standard I attach a patch
that modifies the test suite to align the non-compliant strings with
the alignas() attribute.  The test suite now passes on Alpha with
that patch.

Cheers
Michael

[1] https://buildd.debian.org/status/fetch.php?pkg=mpd&arch=alpha&ver=0.19.14-2&stamp=1461542099
This commit is contained in:
Michael Cree 2016-04-28 22:22:50 +12:00 committed by Max Kellermann
parent 27d4b15925
commit 72637d00e8
2 changed files with 5 additions and 4 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ ver 0.19.15 (not yet released)
- opus: support bigger OpusTags packets
* fix more build failures on non-glibc builds due to constexpr Mutex
* fix build failure due to missing include
* fix unit test on Alpha
ver 0.19.14 (2016/03/18)
* decoder

View File

@ -49,9 +49,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ByteReverseTest);
void
ByteReverseTest::TestByteReverse2()
{
static const char src[] = "123456";
static const char src[] alignas(uint16_t) = "123456";
static const char result[] = "214365";
static uint8_t dest[ARRAY_SIZE(src)];
static uint8_t dest[ARRAY_SIZE(src)] alignas(uint16_t);
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 2);
@ -73,9 +73,9 @@ ByteReverseTest::TestByteReverse3()
void
ByteReverseTest::TestByteReverse4()
{
static const char src[] = "12345678";
static const char src[] alignas(uint32_t) = "12345678";
static const char result[] = "43218765";
static uint8_t dest[ARRAY_SIZE(src)];
static uint8_t dest[ARRAY_SIZE(src)] alignas(uint32_t);
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 4);