From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Hopefully last strncpy fix on IA-64
Date: Sat, 07 Dec 2002 00:52:00 -0000 [thread overview]
Message-ID: <20021207095251.I1310@sunsite.ms.mff.cuni.cz> (raw)
Hi!
test-strncpy segfaults without the strncpy.S patch and works with it.
2002-12-07 Kenneth W. Chen <kenneth.w.chen@intel.com>.
* sysdeps/ia64/strncpy.S (strncpy): Clear ar.ec. Fix .recovery4.
2002-12-07 Jakub Jelinek <jakub@redhat.com>
* string/test-strncpy.c (do_random_tests): Improve test coverage.
--- libc/string/test-strncpy.c.jj 2002-11-09 13:09:59.000000000 +0100
+++ libc/string/test-strncpy.c 2002-12-07 01:52:04.000000000 +0100
@@ -144,32 +144,57 @@ do_test (size_t align1, size_t align2, s
static void
do_random_tests (void)
{
- size_t i, j, n, align1, align2, len, size;
+ size_t i, j, n, align1, align2, len, size, mode;
unsigned char *p1 = buf1 + page_size - 512;
unsigned char *p2 = buf2 + page_size - 512;
unsigned char *res;
for (n = 0; n < ITERATIONS; n++)
{
- align1 = random () & 31;
- if (random () & 1)
- align2 = random () & 31;
- else
- align2 = align1 + (random () & 24);
- len = random () & 511;
- j = align1;
- if (align2 > j)
- j = align2;
- if (random () & 1)
+ mode = random ();
+ if (mode & 1)
{
- size = random () & 511;
- if (size + align2 > 512)
- size = 512 - align2 - (random() & 31);
+ size = random () & 255;
+ align1 = 512 - size - (random () & 15);
+ if (mode & 2)
+ align2 = align1 - (random () & 24);
+ else
+ align2 = align1 - (random () & 31);
+ if (mode & 4)
+ {
+ j = align1;
+ align1 = align2;
+ align2 = j;
+ }
+ if (mode & 8)
+ len = size - (random () & 31);
+ else
+ len = 512;
+ if (len >= 512)
+ len = random () & 511;
}
else
- size = 512 - align2;
- if (len + j >= 511)
- len = 510 - j - (random () & 7);
+ {
+ align1 = random () & 31;
+ if (mode & 2)
+ align2 = random () & 31;
+ else
+ align2 = align1 + (random () & 24);
+ len = random () & 511;
+ j = align1;
+ if (align2 > j)
+ j = align2;
+ if (mode & 4)
+ {
+ size = random () & 511;
+ if (size + j > 512)
+ size = 512 - j - (random() & 31);
+ }
+ else
+ size = 512 - j;
+ if ((mode & 8) && len + j >= 512)
+ len = 512 - j - (random () & 7);
+ }
j = len + align1 + 64;
if (j > 512)
j = 512;
--- libc/sysdeps/ia64/strncpy.S.jj 2002-11-05 23:10:31.000000000 +0100
+++ libc/sysdeps/ia64/strncpy.S 2002-12-07 03:46:41.000000000 +0100
@@ -63,6 +63,8 @@ ENTRY(strncpy)
mov saved_pr = pr // save the predicate registers
.save ar.lc, saved_lc
mov saved_lc = ar.lc // save the loop counter
+ mov ar.ec = 0 // ec is not guaranteed to
+ // be zero upon function entry
.body
cmp.geu p6, p5 = 24, in2
(p6) br.cond.spnt .short_len
@@ -221,7 +223,9 @@ ENTRY(strncpy)
ld8 r[MEMLAT] = [tmp]
br.cond.sptk .back3
.recovery4:
+ cmp.eq p5, p6 = len, r0
add tmp = -MEMLAT * 8, src ;;
- ld8 r[MEMLAT - 1] = [tmp]
+(p6) ld8 r[MEMLAT - 1] = [tmp]
+(p5) mov r[MEMLAT - 1] = r0
br.cond.sptk .back4
END(strncpy)
Jakub
next reply other threads:[~2002-12-07 8:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-07 0:52 Jakub Jelinek [this message]
2002-12-07 1:03 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021207095251.I1310@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).