From patchwork Fri Dec 8 17:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 846385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hwgOU5wr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ytfwp28Dkz9s0g for ; Sat, 9 Dec 2017 04:48:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=YZsQMzztdAqCOIo6f0CSm++mWdVc5KNVPwHYqk3jzYo=; b=hwgOU5wrwDxqao fdp8s7bnJkulM2RllzYO9507bRUOxkmpaAv2suvxdSzrIsIcF7mN8PMqXLa5bpfEDABlbd77OEAMb A9EvS8jM3GJRPQs7fc1/8MuEP6SW1CFbnaTF1zcN6Yk7OEBrdXoCKUkuR8aBjimkixJbEOYDgIUX1 i9TFvSXAcu3paPsy1HJX1EKaO7auJbQg8EgpwGrv6fcAgcH+94e4ep1KrHQ+uhJ0dF4ITXbbojucx PDH9pjBkwAT52pEWkDvlDIWQtPrzQPz52SJBn4vL+VZAgMLdyHUl4LKUVSz+wlne4u0yMGdlgu6wq +EUI+GyvkTBIdOT+2iHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eNMlc-00063X-4a; Fri, 08 Dec 2017 17:48:56 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eNMlZ-0005zF-Ir for linux-snps-arc@lists.infradead.org; Fri, 08 Dec 2017 17:48:55 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 5619724E206F; Fri, 8 Dec 2017 09:48:29 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 3C4D11AF; Fri, 8 Dec 2017 09:48:29 -0800 (PST) Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 0E9C11AD; Fri, 8 Dec 2017 09:48:29 -0800 (PST) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 8 Dec 2017 09:48:12 -0800 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 8 Dec 2017 23:18:11 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.67) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 8 Dec 2017 23:18:11 +0530 From: Vineet Gupta To: Subject: [PATCH] Fix subtle race in tst-cancel2 / tst-cancelx2 Date: Fri, 8 Dec 2017 09:47:56 -0800 Message-ID: <1512755276-1705-1-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.10.161.67] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171208_094853_661785_5C5A38F3 X-CRM114-Status: UNSURE ( 5.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [198.182.47.9 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cupertino Miranda , Vineet Gupta , linux-snps-arc@lists.infradead.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When ran on ARC, these tests would ocassionally fail | [ARCLinux]# for i in 1 2 3 4 5 ; do ./tst-cancel2; echo $?; done | write succeeded | result is wrong: expected 0xffffffff, got 0x1 | 1 <-- fail | 0 <-- pass | 0 <--- pass | 0 <-- pass | write succeeded | result is wrong: expected 0xffffffff, got 0x1 | 1 <-- fail Same test (which originated form glibc) doesn't fail in glibc builds. Turns out there's a subtle race in uclibc version The test creates a new thread, makes it do a looong write call, and parent then cancels the thread, expecting it to unwind out of write call cleanly. However the write (even for 10k bytes) could fnish befor eparent gets a chance ti run and/or cancel - causing the occasional failire. Cc: Cupertino Miranda Fix this subtelty by making it write not just once but forever. Signed-off-by: Vineet Gupta --- test/nptl/tst-cancel2.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c index 45c9e8ea957a..08dd13b10f37 100644 --- a/test/nptl/tst-cancel2.c +++ b/test/nptl/tst-cancel2.c @@ -32,11 +32,7 @@ tf (void *arg) write blocks. */ char buf[100000]; - if (write (fd[1], buf, sizeof (buf)) == sizeof (buf)) - { - puts ("write succeeded"); - return (void *) 1l; - } + while (write (fd[1], buf, sizeof (buf)) > 0); return (void *) 42l; }