From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id D381F3858D1E for ; Mon, 13 Feb 2023 16:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D381F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-16df32f2ffdso5093672fac.1 for ; Mon, 13 Feb 2023 08:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=bXrOpsPevW50MB4l2C8rRpCwhlkBB9QjWvFaKE1z2Wg=; b=xz7JoDR9F+k718fe/p5jny+D8HcWHLawiuxkjXljazlqQ9a89HVRB4Ug4XyyGeVJsd 5WkTF3tJiQN5dhweDED1G1SLT/4IFWx9rIh1XEuwNFSURpdnwtTXb6u2DAYsgVTTe2l8 IyvME5v/e1BZdZGqHXQyPWKd0JLoIy4uVENiAYurtRmCAOVR9PC6barz/5LBwu5dqgJt 8Z8Ovqb3qO5mi9Onqp6L33DLaDxZNY7SwI95irvu4r+WlnGOPwDUOnSrFpDVtQL6URfZ fiJJshD8i2El0BhJNXfzMef384G4n0FCd9PPTDH543h9FX/m5Kh/CoEnOIq6/IAHkP6Q +dNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bXrOpsPevW50MB4l2C8rRpCwhlkBB9QjWvFaKE1z2Wg=; b=ZZsrwCtuA9Kav+OekIp+CA7/pA42czLac2LiXWP1loEdy2hyy3/qZg5eXdTsz2HcUk t7/tg4ciHpBp3li5FZIWM7ABGWww+gJZ3INhsIvA8lN6iLtR4lBaAT3IpFp3sKzUgtXT hslPJHEU6lKFLw4Z9JeMHq6VoERlo2WIri924v+jvMvHSX7lWTjKauDMLV6BIiw2njeG 3rkA6H8IOG/5MgcnvMze/7qF+94eDbupXdGBwf+dlyTNU7mqCEZ4KUrXK0BEzXmErTK5 J75jxjbYt87ZzoZtM356sOFfhqT4P16KdV2FqOt7azYXEdXQVuQQDS5FOzPMRre8CBC7 LpAQ== X-Gm-Message-State: AO0yUKXadtPwdGtu5WnG74cn3ol/bEvNckm4weq3ENh9cX+DI42j1SZD 01ipUNoOdqrJgZXSCvUqaeHFpA== X-Google-Smtp-Source: AK7set+lpXdjC3qIa5ILrbUAtHZkRVUGlQuB52rTyNWVjmn+ELw/f99mPKFf+JviNqab78mG3MRdrA== X-Received: by 2002:a05:6870:17aa:b0:16d:fef6:69b7 with SMTP id r42-20020a05687017aa00b0016dfef669b7mr2711977oae.25.1676305700950; Mon, 13 Feb 2023 08:28:20 -0800 (PST) Received: from [192.168.15.100] ([187.34.211.67]) by smtp.gmail.com with ESMTPSA id du1-20020a0568703a0100b0016a310dc4a9sm281608oab.9.2023.02.13.08.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Feb 2023 08:28:20 -0800 (PST) Message-ID: <92772e3f-4809-ed81-5d3a-796a7dce4f45@linaro.org> Date: Mon, 13 Feb 2023 13:27:02 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [PATCH] stdlib: Undo post review change to 16adc58e73f3 [BZ #27749] Content-Language: en-US To: Vitaly Buka , libc-alpha@sourceware.org Cc: Rasmus Villemoes References: <0a4a8828-ed9a-66d4-f65c-f2f386768bdb@prevas.dk> <20230213060117.3193783-1-vitalybuka@google.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230213060117.3193783-1-vitalybuka@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 13/02/23 03:01, Vitaly Buka wrote: > Post review removal of "goto restart" from > https://sourceware.org/pipermail/libc-alpha/2021-April/125470.html > introduced a bug when some atexit handers skipped. > > Signed-off-by: Vitaly Buka Some minor issues on testcase style, besides that LGTM. I am trying to recall why I have pushed a slight different patch than the one you posted on maillist (most likely my mistake). > --- > stdlib/Makefile | 1 + > stdlib/exit.c | 7 +++- > stdlib/test-atexit-recursive.c | 72 ++++++++++++++++++++++++++++++++++ > 3 files changed, 78 insertions(+), 2 deletions(-) > create mode 100644 stdlib/test-atexit-recursive.c > > diff --git a/stdlib/Makefile b/stdlib/Makefile > index 83391d00c1..8f80571d76 100644 > --- a/stdlib/Makefile > +++ b/stdlib/Makefile > @@ -171,6 +171,7 @@ tests := \ > test-a64l \ > test-at_quick_exit-race \ > test-atexit-race \ > + test-atexit-recursive \ > test-bz22786 \ > test-canon \ > test-canon2 \ > diff --git a/stdlib/exit.c b/stdlib/exit.c > index 6b1eed6445..1cd0bdfe94 100644 > --- a/stdlib/exit.c > +++ b/stdlib/exit.c > @@ -51,7 +51,10 @@ __run_exit_handlers (int status, struct exit_function_list **listp, > exit (). */ > while (true) > { > - struct exit_function_list *cur = *listp; > + struct exit_function_list *cur; > + > + restart: > + cur = *listp; > > if (cur == NULL) > { > @@ -113,7 +116,7 @@ __run_exit_handlers (int status, struct exit_function_list **listp, > if (__glibc_unlikely (new_exitfn_called != __new_exitfn_called)) > /* The last exit function, or another thread, has registered > more exit functions. Start the loop over. */ > - continue; > + goto restart; > } > > *listp = cur->next; > diff --git a/stdlib/test-atexit-recursive.c b/stdlib/test-atexit-recursive.c > new file mode 100644 > index 0000000000..ca832941fe > --- /dev/null > +++ b/stdlib/test-atexit-recursive.c > @@ -0,0 +1,72 @@ > +/* Support file for atexit/exit, etc. race tests (BZ #27749). > + Copyright (C) 2021-2023 Free Software Foundation, Inc. Just 2023 here. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +/* Check that atexit handler registed from another handler still called. */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +static void > +atexit_cb (void) { > +} > + Open brackets in new line: func (void) { > +static void > +atexit_last (void) { > + _exit (1); > +} > + > +static void > +atexit_recursive (void) { > + atexit(&atexit_cb); Space after function name. > + atexit(&atexit_last); > +} > + > +_Noreturn static void > +test_and_exit (int count) > +{ > + for (int i = 0; i < count; ++i) > + atexit(&atexit_cb); > + atexit(&atexit_recursive); > + exit (0); > +} > + > +static int > +do_test (void) > +{ > + for (int i = 0; i < 100; ++i) > + if (xfork () == 0) > + test_and_exit (i); > + > + for (int i = 0; i < 100; ++i) > + { > + int status; > + xwaitpid (0, &status, 0); > + if (!WIFEXITED (status)) > + FAIL_EXIT1 ("Failed iterations %d", i); > + TEST_COMPARE (WEXITSTATUS (status), 1); > + } > + > + return 0; > +} > + > +#define TEST_FUNCTION do_test No need to define TEST_FUNCTION. > +#include