public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [resend] memccpy() question
@ 2003-03-25  9:57 Jes Sorensen
  2003-03-25 10:05 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Jes Sorensen @ 2003-03-25  9:57 UTC (permalink / raw)
  To: libc-hacker; +Cc: srn

(resending from my subscribed email address)

Hi

I have a bug report regarding memccpy() on ia64 and I am not 100% sure
what is supposed to be correct behavior. SuS doesn't seem to be explicit
on this.

The problem is illustrated by the following simple code example:

    ptr = mmap(PAGE_SIZE)
    memccpy(dest, ptr, c, PAGE_SIZE+10)

The string pointed to by ptr contains the character c before the page
boundary. Now what happens is that the ia64 memccpy() implementation
uses software pipelining which does pretty hefty read-ahead and
therefore ends up hitting into the unmapped area before detecting the
character c.

My question is: Is it reasonable to say that memccpy() has a free go at
touching the entire source string as specified by the len argument or is
it valid to expect that you can specify a random length as long as the
character searched for is within the valid area?

Any thoughts?

Thanks,
Jes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [resend] memccpy() question
  2003-03-25  9:57 [resend] memccpy() question Jes Sorensen
@ 2003-03-25 10:05 ` Andreas Schwab
  2003-03-25 10:10   ` Roland McGrath
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2003-03-25 10:05 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: libc-hacker, srn

Jes Sorensen <jes@trained-monkey.org> writes:

|> My question is: Is it reasonable to say that memccpy() has a free go at
|> touching the entire source string as specified by the len argument or is
|> it valid to expect that you can specify a random length as long as the
|> character searched for is within the valid area?

From the POSIX description:

    The memccpy() function shall copy bytes from memory area s2 into s1,
    stopping after the first occurrence of byte c (converted to an
    unsigned char) is copied, or after n bytes are copied, whichever comes
    first.

I'd conclude that memccpy must not touch the memory after the character.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [resend] memccpy() question
  2003-03-25 10:05 ` Andreas Schwab
@ 2003-03-25 10:10   ` Roland McGrath
  2003-03-25 10:40     ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Roland McGrath @ 2003-03-25 10:10 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Jes Sorensen, libc-hacker, srn

> From the POSIX description:
> 
>     The memccpy() function shall copy bytes from memory area s2 into s1,
>     stopping after the first occurrence of byte c (converted to an
>     unsigned char) is copied, or after n bytes are copied, whichever comes
>     first.
> 
> I'd conclude that memccpy must not touch the memory after the character.

I concur.  Note that we have string/stratcliff.c to test exactly this kind
of issue for some other string functions.  It seems appropriate to test
memccpy there too.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [resend] memccpy() question
  2003-03-25 10:10   ` Roland McGrath
@ 2003-03-25 10:40     ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2003-03-25 10:40 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Andreas Schwab, Jes Sorensen, libc-hacker, srn

On Tue, Mar 25, 2003 at 02:05:16AM -0800, Roland McGrath wrote:
> > From the POSIX description:
> > 
> >     The memccpy() function shall copy bytes from memory area s2 into s1,
> >     stopping after the first occurrence of byte c (converted to an
> >     unsigned char) is copied, or after n bytes are copied, whichever comes
> >     first.
> > 
> > I'd conclude that memccpy must not touch the memory after the character.
> 
> I concur.  Note that we have string/stratcliff.c to test exactly this kind
> of issue for some other string functions.  It seems appropriate to test
> memccpy there too.

And string/test-{mem,st}*.c test for the behaviour near the mapping end too,
just test-memccpy.c is not written (yet).

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-03-25 10:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-25  9:57 [resend] memccpy() question Jes Sorensen
2003-03-25 10:05 ` Andreas Schwab
2003-03-25 10:10   ` Roland McGrath
2003-03-25 10:40     ` Jakub Jelinek

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).