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

Bug#825865: glibc: Testsuite failure on sparc64 due to unaligned access in wcsmbs/test-wcsncmp.c



Source: glibc
Version: 2.22-9
Severity: normal
Tags: patch
User: debian-sparc@lists.debian.org
Usertags: sparc64

Hi!

glibc currently fails to build from source on sparc64 due at least one test
in the testsuite failing which is due to a bus error (unaligned access):

----------
XFAIL: wcsmbs/test-wcsncmp
original exit status 1
			wcsncmp	simple_wcsncmp	stupid_wcsncmp
Didn't expect signal from child: got `Bus error'
----------

I have notified glibc upstream of these issue - not in a bug report but by
talking to one of the developers and I have now a patch that fixes the
problem [1].

This patch applies cleanly to glibc 2.22-9 in Debian unstable when dropping
the Changelog part from the upstream patch, so I'm attaching a patch with
this part removed as a suggestion for what to include in the Debian package.

Please note: I was still getting some spurious test failures in rt/tst-mqueue5
due to timeouts. But those could also be a local issue which needs some further
investiogation (might be related to TIMEOUTFACTOR in debian/build.mk).

Cheers,
Adrian

> [1] https://sourceware.org/ml/libc-alpha/2016-05/msg00710.html

-- 
 .''`.  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
Description: Fix string/test-strncmp.c to work with wide chars.
 wcsmbs/test-wcsncmp.c (i.e. string/test-strncmp with defined WIDE)
 triggers a signal in aligment-strict platforms, like sparc*-*-*.
 .
 This patch fixes string/test-strncmp.c to work properly when the test is
 performed on arrays of wide chars.  This includes passing align1 and
 align2 to do_test as bytes, and to use more meaningful values for middle
 chars and large chars.
 .

--- glibc-2.22.orig/string/test-strncmp.c
+++ glibc-2.22/string/test-strncmp.c
@@ -38,6 +38,8 @@
 # define CHAR wchar_t
 # define UCHAR wchar_t
 # define CHARBYTES 4
+# define MIDCHAR 0x7fffffff
+# define LARGECHAR 0xfffffffe
 # define CHAR__MAX WCHAR_MAX
 # define CHAR__MIN WCHAR_MIN
 
@@ -88,6 +90,8 @@ stupid_wcsncmp (const CHAR *s1, const CH
 # define CHAR char
 # define UCHAR unsigned char
 # define CHARBYTES 1
+# define MIDCHAR 0x7f
+# define LARGECHAR 0xfe
 # define CHAR__MAX CHAR_MAX
 # define CHAR__MIN CHAR_MIN
 
@@ -414,56 +418,56 @@ test_main (void)
 
   for (i =0; i < 16; ++i)
     {
-      do_test (0, 0, 8, i, 127, 0);
-      do_test (0, 0, 8, i, 127, -1);
-      do_test (0, 0, 8, i, 127, 1);
-      do_test (i, i, 8, i, 127, 0);
-      do_test (i, i, 8, i, 127, 1);
-      do_test (i, i, 8, i, 127, -1);
-      do_test (i, 2 * i, 8, i, 127, 0);
-      do_test (2 * i, i, 8, i, 127, 1);
-      do_test (i, 3 * i, 8, i, 127, -1);
-      do_test (0, 0, 8, i, 255, 0);
-      do_test (0, 0, 8, i, 255, -1);
-      do_test (0, 0, 8, i, 255, 1);
-      do_test (i, i, 8, i, 255, 0);
-      do_test (i, i, 8, i, 255, 1);
-      do_test (i, i, 8, i, 255, -1);
-      do_test (i, 2 * i, 8, i, 255, 0);
-      do_test (2 * i, i, 8, i, 255, 1);
-      do_test (i, 3 * i, 8, i, 255, -1);
+      do_test (0, 0, 8, i, MIDCHAR, 0);
+      do_test (0, 0, 8, i, MIDCHAR, -1);
+      do_test (0, 0, 8, i, MIDCHAR, 1);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 0);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 1);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, -1);
+      do_test (CHARBYTES * i, 2 * CHARBYTES * i, 8, i, MIDCHAR, 0);
+      do_test (2 * CHARBYTES * i, CHARBYTES * i, 8, i, MIDCHAR, 1);
+      do_test (CHARBYTES * i, 3 * CHARBYTES * i, 8, i, MIDCHAR, -1);
+      do_test (0, 0, 8, i, LARGECHAR, 0);
+      do_test (0, 0, 8, i, LARGECHAR, -1);
+      do_test (0, 0, 8, i, LARGECHAR, 1);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 0);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 1);
+      do_test (CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, -1);
+      do_test (CHARBYTES * i, 2 * CHARBYTES * i, 8, i, LARGECHAR, 0);
+      do_test (2 * CHARBYTES * i, CHARBYTES * i, 8, i, LARGECHAR, 1);
+      do_test (CHARBYTES * i, 3 * CHARBYTES * i, 8, i, LARGECHAR, -1);
     }
 
   for (i = 1; i < 8; ++i)
     {
-      do_test (0, 0, 8 << i, 16 << i, 127, 0);
-      do_test (0, 0, 8 << i, 16 << i, 127, 1);
-      do_test (0, 0, 8 << i, 16 << i, 127, -1);
-      do_test (0, 0, 8 << i, 16 << i, 255, 0);
-      do_test (0, 0, 8 << i, 16 << i, 255, 1);
-      do_test (0, 0, 8 << i, 16 << i, 255, -1);
-      do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 0);
-      do_test (8 - i, 2 * i, 8 << i, 16 << i, 127, 1);
-      do_test (2 * i, i, 8 << i, 16 << i, 255, 0);
-      do_test (2 * i, i, 8 << i, 16 << i, 255, 1);
-    }
-
-  do_test_limit (0, 0, 0, 0, 127, 0);
-  do_test_limit (4, 0, 21, 20, 127, 0);
-  do_test_limit (0, 4, 21, 20, 127, 0);
-  do_test_limit (8, 0, 25, 24, 127, 0);
-  do_test_limit (0, 8, 25, 24, 127, 0);
+      do_test (0, 0, 8 << i, 16 << i, MIDCHAR, 0);
+      do_test (0, 0, 8 << i, 16 << i, MIDCHAR, 1);
+      do_test (0, 0, 8 << i, 16 << i, MIDCHAR, -1);
+      do_test (0, 0, 8 << i, 16 << i, LARGECHAR, 0);
+      do_test (0, 0, 8 << i, 16 << i, LARGECHAR, 1);
+      do_test (0, 0, 8 << i, 16 << i, LARGECHAR, -1);
+      do_test (CHARBYTES * (8 - i), 2 * CHARBYTES * i, 8 << i, 16 << i, MIDCHAR, 0);
+      do_test (CHARBYTES * (8 - i), 2 * CHARBYTES * i, 8 << i, 16 << i, MIDCHAR, 1);
+      do_test (2 * CHARBYTES * i, CHARBYTES * i, 8 << i, 16 << i, LARGECHAR, 0);
+      do_test (2 * CHARBYTES * i, CHARBYTES * i, 8 << i, 16 << i, LARGECHAR, 1);
+    }
+
+  do_test_limit (0, 0, 0, 0, MIDCHAR, 0);
+  do_test_limit (CHARBYTES * 4, 0, 21, 20, MIDCHAR, 0);
+  do_test_limit (0, CHARBYTES * 4, 21, 20, MIDCHAR, 0);
+  do_test_limit (CHARBYTES * 8, 0, 25, 24, MIDCHAR, 0);
+  do_test_limit (0, CHARBYTES * 8, 25, 24, MIDCHAR, 0);
 
   for (i = 0; i < 8; ++i)
     {
-      do_test_limit (0, 0, 17 - i, 16 - i, 127, 0);
-      do_test_limit (0, 0, 17 - i, 16 - i, 255, 0);
-      do_test_limit (0, 0, 15 - i, 16 - i, 127, 0);
-      do_test_limit (0, 0, 15 - i, 16 - i, 127, 1);
-      do_test_limit (0, 0, 15 - i, 16 - i, 127, -1);
-      do_test_limit (0, 0, 15 - i, 16 - i, 255, 0);
-      do_test_limit (0, 0, 15 - i, 16 - i, 255, 1);
-      do_test_limit (0, 0, 15 - i, 16 - i, 255, -1);
+      do_test_limit (0, 0, 17 - i, 16 - i, MIDCHAR, 0);
+      do_test_limit (0, 0, 17 - i, 16 - i, LARGECHAR, 0);
+      do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, 0);
+      do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, 1);
+      do_test_limit (0, 0, 15 - i, 16 - i, MIDCHAR, -1);
+      do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, 0);
+      do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, 1);
+      do_test_limit (0, 0, 15 - i, 16 - i, LARGECHAR, -1);
     }
 
   do_random_tests ();

Reply to: