From: Mathieu Chouquet-Stringer <mchouque@free.fr>
To: Bob Tracy <rct@gherkin.frus.com>,
linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Subject: strncpy (maybe others) broken on Alpha
Date: Thu, 20 Apr 2006 19:11:02 +0200 [thread overview]
Message-ID: <20060420171102.GA7272@localhost> (raw)
In-Reply-To: <20060420101448.GA20087@localhost>
[ some background here: this started as a kobject_add error from the
scsi subsystem, now it appears the strncpy routine on Alpha is broken
see http://lkml.org/lkml/fancy/2006/4/19/305 or
msgid 20060419213129.GA9148@localhost ]
On Thu, Apr 20, 2006 at 12:14:48PM +0200, Mathieu Chouquet-Stringer wrote:
> So I guess the strncpy routine on alpha is fscked up or gcc is doing
> something crazy. The function is under arch/alpha/lib/strncpy.S, time to
> learn assembly.
Replying to myself here, i've created the following test program and
redefined strncpy to mystrncpy (I used strncpy.S and stxncpy.S from
arch/alpha/lib):
=============================================================================
#include <stdio.h>
#include <string.h>
#define FOO 50
extern char *mystrncpy(char *dest, const char *src, size_t count);
int main(int argc, char **argv)
{
char src[FOO] = "";
char dest[FOO];
char letter[] = "a";
int i;
for (i = 0; i < FOO - 1; i++) {
size_t beflen, aftlen;
letter[0] = 'a' + i;
strncat(src, letter, FOO);
beflen = strlen(src);
mystrncpy(dest, src, FOO);
aftlen = strlen(dest);
if (beflen != aftlen)
printf("fails for strlen = %ld (copied %ld)\n",
beflen, aftlen);
}
return 0;
}
=============================================================================
And here's the output using gcc version 3.4.4 (Gentoo 3.4.4-r1,
ssp-3.4.4-1.0, pie-8.7.8), note i didn't use flag except -Wall:
fails for strlen = 3 (copied 2)
fails for strlen = 4 (copied 2)
fails for strlen = 5 (copied 2)
fails for strlen = 6 (copied 2)
fails for strlen = 7 (copied 2)
fails for strlen = 11 (copied 10)
fails for strlen = 12 (copied 10)
fails for strlen = 13 (copied 10)
fails for strlen = 14 (copied 10)
fails for strlen = 15 (copied 10)
fails for strlen = 19 (copied 18)
fails for strlen = 20 (copied 18)
fails for strlen = 21 (copied 18)
fails for strlen = 22 (copied 18)
fails for strlen = 23 (copied 18)
fails for strlen = 27 (copied 26)
fails for strlen = 28 (copied 26)
fails for strlen = 29 (copied 26)
fails for strlen = 30 (copied 26)
fails for strlen = 31 (copied 26)
fails for strlen = 35 (copied 34)
fails for strlen = 36 (copied 34)
fails for strlen = 37 (copied 34)
fails for strlen = 38 (copied 34)
fails for strlen = 39 (copied 34)
fails for strlen = 43 (copied 42)
fails for strlen = 44 (copied 42)
fails for strlen = 45 (copied 42)
fails for strlen = 46 (copied 42)
fails for strlen = 47 (copied 42)
So much for this function... I'll look at the assembly to see if I can
understand what's going on: it always copy a multiple of 8 + 2 bytes (as
in 8x + 2).
--
Mathieu Chouquet-Stringer mchouque@free.fr
next prev parent reply other threads:[~2006-04-20 17:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20060419213129.GA9148@localhost>
[not found] ` <20060419215803.6DE5BDBA1@gherkin.frus.com>
2006-04-20 10:14 ` class_device_add error in SCSI with 2.6.17-rc2-g52824b6b Mathieu Chouquet-Stringer
2006-04-20 10:57 ` Mathieu Chouquet-Stringer
2006-04-20 17:11 ` Mathieu Chouquet-Stringer [this message]
2006-04-20 20:55 ` strncpy (maybe others) broken on Alpha Mathieu Chouquet-Stringer
2006-04-20 21:24 ` Ivan Kokshaysky
2006-04-20 21:27 ` Mathieu Chouquet-Stringer
2006-04-20 21:40 ` Bob Tracy
2006-04-20 21:57 ` Mathieu Chouquet-Stringer
2006-04-21 2:43 ` Bob Tracy
2006-04-21 8:15 ` Mathieu Chouquet-Stringer
2006-04-21 9:21 ` Mathieu Chouquet-Stringer
2006-04-21 9:50 ` Mathieu Chouquet-Stringer
2006-04-21 11:41 ` Bob Tracy
2006-04-21 11:55 ` Mathieu Chouquet-Stringer
2006-04-21 14:22 ` Ivan Kokshaysky
2006-04-21 19:37 ` Bob Tracy
2006-04-21 21:12 ` Ivan Kokshaysky
2006-04-21 22:49 ` Bob Tracy
2006-04-22 8:47 ` Mathieu Chouquet-Stringer
2006-04-22 8:45 ` Mathieu Chouquet-Stringer
2006-04-22 10:39 ` Bryan Østergaard
2006-04-20 21:22 ` Ivan Kokshaysky
2006-04-20 21:25 ` Mathieu Chouquet-Stringer
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=20060420171102.GA7272@localhost \
--to=mchouque@free.fr \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rct@gherkin.frus.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 NNTP newsgroup(s).