NetBSD Problem Report #51885
From www@NetBSD.org Sun Jan 15 20:40:31 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id C28E57A2BE
for <gnats-bugs@gnats.NetBSD.org>; Sun, 15 Jan 2017 20:40:31 +0000 (UTC)
Message-Id: <20170115204030.E3B937A2BF@mollari.NetBSD.org>
Date: Sun, 15 Jan 2017 20:40:30 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] tests/lib/libpthread/t_detach: eliminate races
X-Send-Pr-Version: www-1.0
>Number: 51885
>Category: bin
>Synopsis: [PATCH] tests/lib/libpthread/t_detach: eliminate races
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jan 15 20:45:00 +0000 2017
>Closed-Date: Mon Jan 16 18:30:00 +0000 2017
>Last-Modified: Mon Jan 16 18:30:00 +0000 2017
>Originator: Ngie Cooper
>Release: 7.0.2
>Organization:
>Environment:
n/a
>Description:
Add sleep's between pthread_detach'es so the invariants can be tested properly (we ran into spurious failures at $work when testing on VMware VMs -- this fixes the issue).
Sort #includes
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51885: [PATCH] tests/lib/libpthread/t_detach: eliminate races
Date: Sun, 15 Jan 2017 13:00:47 -0800
--Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Patch attached.
-Ngie
--Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9
Content-Disposition: attachment;
filename=t_detach-defeat-races.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_detach-defeat-races.patch"
Content-Transfer-Encoding: 7bit
Index: lib/libpthread/t_detach.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libpthread/t_detach.c,v
retrieving revision 1.1
diff -u -r1.1 t_detach.c
--- lib/libpthread/t_detach.c 24 Mar 2011 13:52:04 -0000 1.1
+++ lib/libpthread/t_detach.c 15 Jan 2017 20:54:32 -0000
@@ -31,8 +31,9 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $");
-#include <pthread.h>
#include <errno.h>
+#include <pthread.h>
+#include <time.h>
#include <atf-c.h>
@@ -43,6 +44,7 @@
static void *
func(void *arg)
{
+ sleep(2);
return NULL;
}
@@ -72,14 +74,17 @@
*/
PTHREAD_REQUIRE(pthread_detach(t));
+ sleep(1);
rv = pthread_join(t, NULL);
ATF_REQUIRE(rv == EINVAL);
+ sleep(3);
+
/*
* As usual, ESRCH should follow if
* we try to detach an invalid thread.
*/
- rv = pthread_cancel(NULL);
+ rv = pthread_cancel(t);
ATF_REQUIRE(rv == ESRCH);
}
--Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9--
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51885 CVS commit: src/tests/lib/libpthread
Date: Mon, 16 Jan 2017 11:29:55 -0500
Module Name: src
Committed By: christos
Date: Mon Jan 16 16:29:54 UTC 2017
Modified Files:
src/tests/lib/libpthread: t_detach.c
Log Message:
PR/51885: Ngie Cooper: Add delays to avoid races.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_detach.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Mon, 16 Jan 2017 18:30:00 +0000
State-Changed-Why:
christos committed it. thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.