[PATCH] Fix test-wcsncmp BUS errors.
Carlos O'Donell
carlos@redhat.com
Thu Jul 23 17:55:00 GMT 2015
On 07/21/2015 05:39 PM, David Miller wrote:
> As currently coded, the strncmp tests dereference unaligned pointers
> when setting up the test patterns. This results in SIGBUS errors
> on Sparc, for example.
>
> Force the alignment arguments to be aligned properly for the character
> type being tested.
The test is designed to show that alignment of the strings should not
impact the result of the testing. However, I agree that the fundamental
alignment of wchar_t and char need to be preserved. The latter is easily
preserved, not so with the former.
> Ok to commit?
>
> 2015-07-21 David S. Miller <davem@davemloft.net>
>
> * string/test-strncmp.c (do_test_limit): Align align1 and align2
> to CHARBYTES.
> (do_test): Likewise.
>
> diff --git a/string/test-strncmp.c b/string/test-strncmp.c
> index fb57a9b..277eb2c 100644
> --- a/string/test-strncmp.c
> +++ b/string/test-strncmp.c
> @@ -156,6 +156,9 @@ do_test_limit (size_t align1, size_t align2, size_t len, size_t n, int max_char,
> size_t i, align_n;
> CHAR *s1, *s2;
>
> + align1 &= ~(CHARBYTES - 1);
> + align2 &= ~(CHARBYTES - 1);
This would make testing any align1 or align2 below CHARBYTES moot for
wchar_t, when what we really want is alignment in *addition* to the
minimum basic alignment for the type.
Can't we shift align1 and align2 by CHARBYTES - 1 to achieve that and
apply it?
If you have to align please use #include <libc-internal.h> PTR_ALIGN_*
or ALIGN_* macros.
> +
> if (n == 0)
> {
> s1 = (CHAR *) (buf1 + page_size);
> @@ -204,6 +207,9 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char,
> size_t i;
> CHAR *s1, *s2;
>
> + align1 &= ~(CHARBYTES - 1);
> + align2 &= ~(CHARBYTES - 1);
> +
> if (n == 0)
> return;
>
>
Post v2 please.
Cheers,
Carlos.
More information about the Libc-alpha
mailing list