This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: segfault in test-strcmp


On Thu, Nov 07, 2002 at 06:44:04PM -0800, Roland McGrath wrote:
> I looked at the test-strchr crash before the test-strcmp one, but I suspect
> the problem is similar.  The sysdeps/powerpc/powerpc32/strchr.S code is
> accessing the word following the word containing the search character.
> This faults because the test string is aligned on the end of a page so that
> the following word cannot be accessed (this happens on iteration 157 in
> test-strchr with no srandom).  The test program is arguably invoking
> undefined behavior, because the string is actually not terminated: the
> final word of the page contains the search character and three other
> nonzero bytes.  So a stupid but valid implementation of strchr that called
> strlen would crash.

The test should probably just test defined behaviour, so
should terminate all strings, or at least have an option whether it allows
accesses past the place where string differs or where searched char was
found (by default only testing with zero terminated strings).
Will look into this.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]