From patchwork Fri Dec 28 01:02:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 154578 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7504233ljp; Thu, 27 Dec 2018 17:03:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/UgawR1YqkI14315t38rFZqV/LNfepj0mRJ0cX5opOwUyVFgifoFZzf3pq+bWoPPTt2IYel X-Received: by 2002:a62:d885:: with SMTP id e127mr25911075pfg.197.1545959002671; Thu, 27 Dec 2018 17:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545959002; cv=none; d=google.com; s=arc-20160816; b=es1OU4GISqZEpsHZ9xs5Btu8ewPV4d8EjWbELXSxywW1lMWpO2G1sdfEgnA0g7k35U f3Eo9Um7MidcvIdc5HPtJ9c/KczDD+r2+sa+IJIgtxD991t++DoA9GGGwxiCJl7/557e 4gs7wt0Ab4egcm9bH2lxHlgVRqnQINAKdzyzP4cBQKt/D3H4IG5FM5RyOSKuw08EYTJV ioA/mmW/KsQwd7PuJ+0aZxEUVxMxKu6QuX3/qicam45bdvt/aGEX9dLOvSqoJ2fuoyPv Mf0Mtm8c1IMAgzGGVFDuKijJuvIqOE3kzAJvK4lX61Ke6gqgE0VVe/Zetp33wGzYI84V vZSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=sHwaooOHDVgMVCIgf5T3xOkXrhPOlcRRg5pvWasicX4=; b=x5OSJmKwEvNcBQwPh0cw/PLAEnCFXYIKkr+ro4WfbgHBTg1nFXWRAyKbuPsdOpAOru YaqwLNmLXp4cmTBppqlPRbmxfPgkrUjjnJ4I4ASGa8XFMgatq1ELs9VAT/X5GIBrIo28 Do4vbxcVQrQLmkNpb8YKlXKDBgMlcZRMKw50eoXRNANTFI1Tsln5aBb13OvtVQiDNF12 HkE6Fuc5osUgU9dEQPL5Yfa/1bKyYP49/i9fNd7YfJs6vbjNDZMDuCHVSA0LNBt1dLSk bIGKIt/zckbNdjCDyJXogGf0Yodkm2R4bil+G7qAxhlNhpkWoPwsKlBeKFBeQESgDo9q SpnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=c98SYSEL; dkim=pass header.i=@linaro.org header.s=google header.b=bvzZOaxZ; spf=pass (google.com: domain of libc-alpha-return-98814-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98814-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o12si36462616pgn.145.2018.12.27.17.03.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 17:03:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-98814-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=c98SYSEL; dkim=pass header.i=@linaro.org header.s=google header.b=bvzZOaxZ; spf=pass (google.com: domain of libc-alpha-return-98814-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-98814-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=tNWyqfO9d/31Jw1TcieuU6tYQx05YeZ P7La/deL/JF/uiHOSpTlAG/x9EFnCFqxzEuKR5rDZJRLjMRUftZivoIfMx70YZHK 2gP0vdfMFuN7DKIHXxXTTQZ/qPG9tl8JwSmY95KeOLtYrWEgHffuIfKgRUwT7OUs 3SwdsPPC4OEA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=FBJi2oDFWGZLoeXbyfd9w+be9v4=; b=c98SY SELBYGSPzD2lo+KntCxt5W9PXphzm/qEtVuNleQMsFG6CuvSP1MkcvsVanCKLoFI dUGT6b/IOX3wpLWc8+FRiAcJ7+ahbNlXcye52vRYsyRHkVk0lZJ+NXzwmqWopbCs 11JEdEZDQmDGDKQooCejXL4827b2HSvfDyXY1o= Received: (qmail 35047 invoked by alias); 28 Dec 2018 01:03:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 34956 invoked by uid 89); 28 Dec 2018 01:03:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=upcoming, 56, act X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sHwaooOHDVgMVCIgf5T3xOkXrhPOlcRRg5pvWasicX4=; b=bvzZOaxZoht1gVMkz8THmFsttkhI3Wwk9NWv5/0t16sGhVoxjYeU6G9lHv+KbHjHFR wuHKCV8IR1Nnl8q9g9w06TjrKhWYclgRwjQvfj+y1MX+bE1M/cKUjgrBPmDCLDLXyh/U l5T+15hlOnrtFU7+xnu4siyV1ZEVJPgJ5vJOI= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH v2 2/6] nptl: Fix testcases for new pthread cancellation mechanism Date: Thu, 27 Dec 2018 23:02:51 -0200 Message-Id: <20181228010255.21406-3-adhemerval.zanella@linaro.org> In-Reply-To: <20181228010255.21406-1-adhemerval.zanella@linaro.org> References: <20181228010255.21406-1-adhemerval.zanella@linaro.org> From: Adhemerval Zanella With upcoming fix for BZ#12683, pthread cancellation does not act for: 1. If syscall is blocked but with some side effects already having taken place (e.g. a partial read or write). 2. After the syscall has returned. The main change is due the fact programs need to act in syscalls with side-effects (for instance, to avoid leak of allocated resources or handle partial read/write). This patch changes the NPTL testcase that assumes the old behavior and also changes the tst-backtrace{5,6} to ignore the cancellable wrappers. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc-linux-gnu, sparcv9-linux-gnu, and sparc64-linux-gnu. * debug/tst-backtrace5.c (handle_signal): Avoid cancellable wrappers in backtrace analysis. * nptl/tst-cancel4.c (tf_write): Handle cancelled syscall with side-effects. (tf_send): Likewise. --- ChangeLog | 6 ++++++ debug/tst-backtrace5.c | 19 ++++++++++--------- nptl/tst-cancel4.c | 8 ++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/debug/tst-backtrace5.c b/debug/tst-backtrace5.c index 0e6fb1a024..dad741e12a 100644 --- a/debug/tst-backtrace5.c +++ b/debug/tst-backtrace5.c @@ -69,17 +69,18 @@ handle_signal (int signum) FAIL (); return; } - /* Do not check name for signal trampoline. */ - i = 2; - if (!match (symbols[i++], "read")) + + /* Do not check name for signal trampoline or cancellable syscall + wrappers (__syscall_cancel*). */ + for (; i < n - 1; i++) + if (match (symbols[i], "read")) + break; + if (i == n - 1) { - /* Perhaps symbols[2] is __kernel_vsyscall? */ - if (!match (symbols[i++], "read")) - { - FAIL (); - return; - } + FAIL (); + return; } + for (; i < n - 1; i++) if (!match (symbols[i], "fn")) { diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 05325385b1..45b3d43c3b 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -166,6 +166,10 @@ tf_write (void *arg) char buf[WRITE_BUFFER_SIZE]; memset (buf, '\0', sizeof (buf)); s = write (fd, buf, sizeof (buf)); + /* The write can return a value higher than 0 (meaning partial write) + due to the SIGCANCEL, but the thread may still be pending + cancellation. */ + pthread_testcancel (); pthread_cleanup_pop (0); @@ -743,6 +747,10 @@ tf_send (void *arg) char mem[WRITE_BUFFER_SIZE]; send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0); + /* The send can return a value higher than 0 (meaning partial send) + due to the SIGCANCEL, but the thread may still be pending + cancellation. */ + pthread_testcancel (); pthread_cleanup_pop (0);