From patchwork Mon Jan 28 14:15:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 31230 Received: (qmail 83754 invoked by alias); 28 Jan 2019 14:15:53 -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 83687 invoked by uid 89); 28 Jan 2019 14:15:52 -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=H*r:ip*192.168.1.132, H*p:D*org X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Yt59i7rkGqvyEL11aHgsM8KUyfU7AQUkfXUvNbrQFag=; b=HT2P8XTJi9BhY1w6cLUuNTWic1inz9jAeFoaj1X5EPOr+cDwYgc8NWaKLGZM+l67Kq CosqB7iHLTn8X4MaxpPvTgBtf9ZIL9ZVI/33X8SBl9QBp6oANg8XmLkMLM8N/TgaDeWi 9obDbL/fUJ+AYvvktuYay6jJGrN2ELtJr/xTg= Return-Path: Subject: Re: [PATCH] posix/tst-spawn: Fix racy tests in spawned processes. To: libc-alpha@sourceware.org References: From: Adhemerval Zanella Openpgp: preference=signencrypt Message-ID: Date: Mon, 28 Jan 2019 12:15:43 -0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: On 28/01/2019 11:41, Stefan Liebler wrote: > Hi, > > from time to time I get fails in tst-spawn like: > tst-spawn.c:111: numeric comparison failure >    left: 0 (0x0); from: xlseek (fd2, 0, SEEK_CUR) >   right: 28 (0x1c); from: strlen (fd2string) > error: 1 test failures > tst-spawn.c:252: numeric comparison failure >    left: 1 (0x1); from: WEXITSTATUS (status) >   right: 0 (0x0); from: 0 > error: 1 test failures > > It turned out, that a child process is testing it's open file descriptors with e.g. a sequence of testing the current position, setting the position to zero and reading a specific amount of bytes. > > Unfortunately starting with commit 2a69f853c03034c2e383e0f9c35b5402ce8b5473 the test is spawning a second child process which is sharing some of the file descriptors.  If the test sequence as mentioned above is running in parallel it leads to test failures. > > As the second call of posix_spawn shall test a NULL pid argument, this patch is just moving the waitpid of the first child before the posix_spawn of the second child. > > Okay for commit? > (I assume 2.30) > > Bye, > Stefan > > ChangeLog: > >     * posix/tst-spawn do_test(): Move waitpid before posix_spawn. > It looks you forgot to add the patch itself on the message, but based on the description I think you meant something like the below: right? diff --git a/posix/tst-spawn.c b/posix/tst-spawn.c index eea5add..2aa0dcc 100644 --- a/posix/tst-spawn.c +++ b/posix/tst-spawn.c @@ -237,25 +237,25 @@ do_test (int argc, char *argv[]) TEST_COMPARE (posix_spawn (&pid, argv[1], &actions, NULL, spargv, environ), 0); - /* Same test but with a NULL pid argument. */ - TEST_COMPARE (posix_spawn (NULL, argv[1], &actions, NULL, spargv, environ), - 0); - - /* Cleanup. */ - TEST_COMPARE (posix_spawn_file_actions_destroy (&actions), 0); - free (name3_copy); - /* Wait for the children. */ TEST_COMPARE (xwaitpid (pid, &status, 0), pid); TEST_VERIFY (WIFEXITED (status)); TEST_VERIFY (!WIFSIGNALED (status)); TEST_COMPARE (WEXITSTATUS (status), 0); + /* Same test but with a NULL pid argument. */ + TEST_COMPARE (posix_spawn (NULL, argv[1], &actions, NULL, spargv, environ), + 0); + xwaitpid (-1, &status, 0); TEST_VERIFY (WIFEXITED (status)); TEST_VERIFY (!WIFSIGNALED (status)); TEST_COMPARE (WEXITSTATUS (status), 0); + /* Cleanup. */ + TEST_COMPARE (posix_spawn_file_actions_destroy (&actions), 0); + free (name3_copy); + return 0; }