mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: New daily reports - debugging alloc.c still
Date: Sun, 7 Aug 2011 03:32:24 -0400	[thread overview]
Message-ID: <20110807073224.GG132@brightrain.aerifal.cx> (raw)
In-Reply-To: <4E3DFB5D.8040008@gmail.com>

On Sun, Aug 07, 2011 at 04:41:33AM +0200, Luka Marčetić wrote:
> What the title says.
> 
> Priorities:
> * figure out how to continue writing pthread_eintr.c so that it
> works regarless of the nr of cores, write as many of function tests
> as possible

It would really help if I could see your progress on this. I suspect
you're over-thinking it. For any pthread function that will block/wait
(e.g. to obtain a lock), hitting it with a signal and checking for
EINTR is not a difficult race condition. It's like hunting turtles
with a sniper rifle. The target thread is just sitting there waiting
for you to signal it.

I would do something like this:

1. Tell the target thread to make the call that will block.

2. Sleep for a fraction of a second to give it time to wake up and
make the call.

3. Send the signal.

4. Sleep again for a fraction of a second to give it time to get
interrupted, if it's going to.

5. Do whatever's needed to unblock the call (e.g. if the thread is
blocked on pthread_mutex_lock, unlock the mutex it's trying to lock).

6. Check the return value of the call to see whether it was 0 or EINTR
(or possibly something else).

For calls which don't block, it's a lot harder to test and you may
need a race approach, but I would consider them very low priority for
testing, since a good implementation won't do anything that would
return EINTR here.

> * apply different tools on setuid.c to remove the hang, employ the
> strategy from point one here as well
> (in both cases, the program is trying to interrupt a child's function call)

Would you like me to send you the setuid test I have working on my
system? It might need some tweaking to hit the race on single-core
machines but you're welcome to use it for ideas or as a starting
point.

> * go through alloc.c again, to hopefully get an idea of why there
> are "unexpected features".

By the way, buf.c is crashing for me in free(), which means something
clobbered the heap. I think we discussed this before: allocating just
the right amount of memory and waiting for a crash is not a valid
test, because you've trashed the heap state at that point, and it
might or might not be detectable due to UB. If you want to look for
crashes you could follow the string functions test approach (mmap at
least 2 pages, with a non-accessible page at the end) but I think it
would probably work just as well just to allocate buffers that are a
plenty large, pre-fill the buffer with a pattern, and make sure the
pattern has not been clobbered past the zone the function was
permitted to write to.

(Note that the reason we needed the mmap thing for string functions
was that we were not just testing for out-of-bounds writes but also
out-of-bounds reads.)


Rich


  parent reply	other threads:[~2011-08-07  7:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 22:14 New daily reports Luka Marčetić
2011-08-03 22:46 ` Solar Designer
2011-08-04 10:51   ` Luka Marčetić
2011-08-04 11:54     ` Solar Designer
2011-08-04 12:01       ` Luka Marčetić
2011-08-04 12:12         ` Solar Designer
2011-08-05  0:02     ` New daily reports - started pthread_eintr.c Luka Marčetić
2011-08-05  0:10       ` Solar Designer
2011-08-06  4:40       ` New daily reports - debugging alloc.c et al Luka Marčetić
2011-08-06 11:15         ` Szabolcs Nagy
2011-08-06 11:50           ` Szabolcs Nagy
2011-08-06 14:34             ` Szabolcs Nagy
2011-08-06 15:38               ` Szabolcs Nagy
2011-08-07  2:41         ` New daily reports - debugging alloc.c still Luka Marčetić
2011-08-07  2:50           ` Solar Designer
2011-08-07  7:32           ` Rich Felker [this message]
2011-08-07 22:25             ` Luka Marčetić
2011-08-09  3:02               ` New daily reports - buf.c Luka Marčetić
2011-08-10  1:34                 ` New daily reports - nothing Luka Marčetić
2011-08-10  1:38                   ` Rich Felker
2011-08-10 11:47                     ` Luka Marčetić
2011-08-10  2:02                   ` Solar Designer
2011-08-10 11:23                     ` Luka Marčetić
2011-08-10 11:56                       ` Solar Designer
2011-08-10 12:13                         ` Luka Marčetić
2011-08-10  2:07                   ` Solar Designer
2011-08-10  2:12                     ` Rich Felker
2011-08-10  4:59                   ` Rich Felker
2011-08-10 12:09                     ` Luka Marčetić
2011-08-10 12:44                     ` Luka Marčetić
2011-08-10 14:25                       ` Rich Felker
2011-08-10 17:21                         ` Luka Marčetić
2011-08-10 17:33                           ` Rich Felker
2011-08-10 18:23                             ` Luka Marčetić
2011-08-10 18:21                               ` Rich Felker
2011-08-10 18:34                                 ` Luka Marčetić
2011-08-10 18:33                                   ` Rich Felker
2011-08-14 20:00                     ` Rich Felker
2011-08-15 14:14                       ` Luka Marčetić

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=20110807073224.GG132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.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.
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).