mailing list of musl libc
 help / color / mirror / code / Atom feed
* Simple testing task - string functions
@ 2011-04-10  4:45 Rich Felker
  2011-04-10 12:08 ` Luka Marčetić
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Rich Felker @ 2011-04-10  4:45 UTC (permalink / raw)
  To: musl

Here's a testing task (particularly for Luka who's applied for SoC)
I'd like to see written. It's based on a recent bug that turned up in
strchr. The interfaces to be tested are strlen, strchr, strcspn,
strspn, memchr, etc. - any string/memory function that scans a range
of memory and needs to stop when it hits a byte matching certain
conditions. We're looking to detect invalid memory access past the end
of the object, and tests should go something like:

1. Allocate two pages of memory with mmap and make the second one
unreadable and unwritable using mprotect.

2. Arrange for the byte that stops the scan to be either the last byte
of the first page, or one of the previous 7 bytes (try them all). Note
that for some interfaces, there are more than one way the scan can be
terminated (e.g. either a matching character of a null terminator) in
which case you want to test both.

3. For each choice of terminator location and type in 2, you want to
test every possible length and alignment leading up to it. You should
test starting the scan exactly at the terminator, one byte before it,
2 bytes before it, ... all the way back to the beginning of the page.

4. Make sure you test both with high and low bytes (8th bit on or off)
as both the non-terminating and terminating bytes, in order to also
catch any errors due to signedness of char.

A signal handler for SIGSEGV, along with siglongjmp to exit the signal
handler, may be convenient for allowing the tests to continue in the
event of a failure or at least reporting which test the failure
occurred in.

Please don't spend time developing any fancy framework for this. It
should take just a few hours to get something working, and most of the
code can be in main() for all I care as long as it works. Part of the
criterion for working is that it should detect the strchr misaligned
read bug in 0.7.6 that was fixed in 0.7.7, and the signedness bug in
0.7.5 that was fixed in 0.7.6.


Rich


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

end of thread, other threads:[~2011-05-02 13:52 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-10  4:45 Simple testing task - string functions Rich Felker
2011-04-10 12:08 ` Luka Marčetić
2011-04-10 15:25 ` JIghtuse
2011-04-10 15:34   ` Rich Felker
2011-04-10 15:46   ` keep discussion threads separate (was: Simple testing task - string functions) Solar Designer
2011-04-14 17:59 ` Simple testing task - string functions Luka Marčetić
2011-04-14 23:11   ` Rich Felker
2011-04-18 12:20     ` Luka Marčetić
2011-04-25 19:34     ` Unit tests Luka Marčetić
2011-04-26 19:14       ` Solar Designer
2011-04-27  0:32         ` Rich Felker
2011-04-27  0:42       ` Rich Felker
2011-04-27  6:29         ` Luka Marčetić
2011-04-29  5:36           ` Solar Designer
2011-04-29 11:54             ` Christian Neukirchen
2011-05-01 19:36               ` Solar Designer
2011-05-02  8:51                 ` Christian Neukirchen
2011-05-02 12:49                   ` Solar Designer
2011-05-02 13:02                     ` errno
2011-05-02 13:11                       ` Rich Felker
2011-05-02 13:30                         ` Solar Designer
2011-05-02 13:32                           ` Rich Felker
2011-05-02 13:52                             ` Solar Designer
2011-05-02 13:27                       ` Solar Designer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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