From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/346 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: New daily reports - debugging alloc.c still Date: Sun, 7 Aug 2011 03:32:24 -0400 Message-ID: <20110807073224.GG132@brightrain.aerifal.cx> References: <4E39C84F.8060705@gmail.com> <20110803224651.GB11437@openwall.com> <4E3A79B2.8090204@gmail.com> <4E3B331E.7050502@gmail.com> <4E3CC5AC.3070404@gmail.com> <4E3DFB5D.8040008@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1312703102 24085 80.91.229.12 (7 Aug 2011 07:45:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 7 Aug 2011 07:45:02 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-347-gllmg-musl=m.gmane.org@lists.openwall.com Sun Aug 07 09:44:59 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Qpy2c-0003KF-Hj for gllmg-musl@lo.gmane.org; Sun, 07 Aug 2011 09:44:58 +0200 Original-Received: (qmail 3306 invoked by uid 550); 7 Aug 2011 07:44:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3292 invoked from network); 7 Aug 2011 07:44:55 -0000 Content-Disposition: inline In-Reply-To: <4E3DFB5D.8040008@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:346 Archived-At: 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