This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix test-wcsncmp BUS errors.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: David Miller <davem at davemloft dot net>, libc-alpha at sourceware dot org
- Date: Thu, 23 Jul 2015 13:55:50 -0400
- Subject: Re: [PATCH] Fix test-wcsncmp BUS errors.
- Authentication-results: sourceware.org; auth=none
- References: <20150721 dot 143904 dot 2006742147973414532 dot davem at davemloft dot net>
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.