From patchwork Sun Oct 22 20:51:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 116635 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3952178qgn; Sun, 22 Oct 2017 13:52:21 -0700 (PDT) X-Received: by 10.99.114.81 with SMTP id c17mr10110517pgn.43.1508705541023; Sun, 22 Oct 2017 13:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508705541; cv=none; d=google.com; s=arc-20160816; b=oId0DT51k56BMkc49mFWxb63fnOw/QXr5sVExLgEVF8xCtMdapzpp3l1PKLL+MGg2G 1EFdGzbR/+w4Nf1SyoEBi9uMWnb+5p1VY6gi7FZcLGCz6v2uIX7q3DuEi6Lgak3Rqkkz G4kTzAadwZVoOx5tqYRi8EJRqPHkgFo26A+a0xJ58wuq/rpWA4d5H/xQgmUB+xjECAcx j5GrN35cEWXRIqjYoUJdGvc1QSpS/kMZfbjy5FAFOnc2YE1jWl7QL2nruCXENkjr1ZUj hMO+DPL2hUMaTY1Sir1RdZ4m5oZBGu+PdenALARAadOIbPhlR84IFMQNkoQs++hNzjYe YOhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=e0kem5fASr8Wp8h9EPDZK1Ct3vj4e0wdywWiCw94/rQ=; b=YopwUuCW+l9Hf94bl/xqscf13zDxyxVV0fq4KxFFeSj9GnTLAl3u7f9YnJG9zguxPe WLxdHTfrgRsDaD5d3ng2cTyglRkeYTo2/ediF8hTIptW6O7q+LVFPnFntnY7CG33sPf4 Q2QzcHXII+8kYMO18ZeDhmu6u8heSUQ3gWtDfywa/A6fvbx86u2dtXJvgbpXfDS2uu0L 2Y5VWis3mUTOfZzRJIuij7ckYO8+jxKcc26TkwH1FCMWOHH2K+fRo/SgSl8575vxKxrL 9ycRG46gjLsNAzERv4cxJlyPK4X4ZpBRRiwM72OcC2Gf/54ZDjpi0XfjgeKnKzRnFeQK xpvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=s/ptyAd/; spf=pass (google.com: domain of libc-alpha-return-86259-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86259-patch=linaro.org@sourceware.org; dmarc=fail (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 x4si3940494pgc.320.2017.10.22.13.52.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Oct 2017 13:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86259-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=s/ptyAd/; spf=pass (google.com: domain of libc-alpha-return-86259-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86259-patch=linaro.org@sourceware.org; dmarc=fail (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:subject:date:message-id; q=dns; s= default; b=UOSIq0Dux6m+YhSKkSPtvmunWf7+VgPZ/Kqh8d5iesfSK8UCNpFuz twP3OSlLAGdWXRsdG8bjJZ8prB9ztHA5G9PalKjvYEWDSjMu+/0ML/LPI9qDlOMt PfcX4+dDNVTVUMVmhZf5cATzsgW7icLF34H9Tt/WF03LqTCX4osIOs= 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:subject:date:message-id; s=default; bh=7q7CCH0P+5ySdT057uLa5tC9Ng4=; b=s/ptyAd/N/UMHP/NP9G2N0z//Ohz +ZhuCWKLGoW+H2j3q1jGFpJ0e9O/MSqm6it8DSeuJ2JR204u0XomJiUSm2OoKFvG wQO1g26/QL42mmF/R4Li27wbxsrfSntuhYcwUX/VqcApxlneXEHx7cpe67042khJ lC2uqxOT1Z5ShwE= Received: (qmail 5404 invoked by alias); 22 Oct 2017 20:52:08 -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 5394 invoked by uid 89); 22 Oct 2017 20:52:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=e0kem5fASr8Wp8h9EPDZK1Ct3vj4e0wdywWiCw94/rQ=; b=GB7Mazpf2CIz/cQTgBLk0U/CBC5YDi/PM/32ZzUw0OwE7fUOkdhpJyUU4bZKoMC8qn c+RN94dIpjxvwlsQ7HkjNIY+Niu/a8jqGbuN8OK6wCp0VQ7+R9CMmM62w0xyZvyDLX/H UAxNPI62KJwDVquH+N42epjqRLW8ZfiI7IbAd8st7rxcWvioxBd7c5OCnz7jWB1d4oRX ov+LYEzHFvJxhlnOI41OBhMPXY08lB0viiinAdyyL+3HHI3xHb9EYXBp7hUjeDyMJItv +KUPhy82VhxHy5wYZbtAKfzsQWhBdqnSSsnomfaccMl+kqPto8IVP5V39FQ4qekpJjri 7kfw== X-Gm-Message-State: AMCzsaXGq7AS6JW1ARxLvuLxsJyWTQ9PkicWZuSZEzmY2ENlnM+BNobm WXoXjry+zbqtGxHxVsXADUIOjuouS2U= X-Google-Smtp-Source: ABhQp+TxP6nmz2cp4EfeVVNcZPCVXMpkMpekj43LhNLVPWTdgdgeanwPWItQdYsc+bCenJKTtA6Z9g== X-Received: by 10.233.222.135 with SMTP id s129mr15768023qkf.261.1508705524419; Sun, 22 Oct 2017 13:52:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] posix: Do not use WNOHANG in waitpid call for Linux posix_spawn Date: Sun, 22 Oct 2017 18:51:57 -0200 Message-Id: <1508705517-31558-1-git-send-email-adhemerval.zanella@linaro.org> As shown in some buildbot issues on aarch64 and powerpc, calling clone (VFORK) and waitpid (WNOHANG) does not guarantee the child is ready to be collected. This patch changes the call back to 0 as before fe05e1cb6d64 fix. This change can lead to the scenario 4.3 described in the commit, where the waitpid call can hang undefinitely on the call. However this is also a very unlikely and also undefinied situation where both the caller is trying to terminate a pid before posix_spawn returns and the race pid reuse is triggered. I don't see how to correct handle this specific situation within posix_spawn. Checked on x86_64-linux-gnu, aarch64-linux-gnu and powerpc64-linux-gnu. * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Use 0 instead of WNOHANG in waitpid call. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/spawni.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index d15fbb1..fb83c2e 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -374,12 +374,12 @@ __spawnix (pid_t * pid, const char *file, ec = args.err; if (ec > 0) /* There still an unlikely case where the child is cancelled after - setting args.err, due to a positive error value. Also due a + setting args.err, due to a positive error value. Also there is possible pid reuse race (where the kernel allocated the same pid - to unrelated process) we need not to undefinitely hang expecting - an invalid pid. In both cases an error is returned to the - caller. */ - __waitpid (new_pid, NULL, WNOHANG); + to an unrelated process). Unfortunately due synchronization + issues where the kernel might not have the process collected + the waitpid below can not use WNOHANG. */ + __waitpid (new_pid, NULL, 0); } else ec = -new_pid;