From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id D39803858D33 for ; Tue, 28 Feb 2023 14:29:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D39803858D33 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-x2d.google.com with SMTP id 586e51a60fabf-1720600a5f0so11030761fac.11 for ; Tue, 28 Feb 2023 06:29:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677594547; 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=oVw5vMuMZUFFaMpO4p5gOvCj1Hyho47Y0PK17bHYiRM=; b=qS0TGKVcKz1DM2sWjlkgUB3trvDIUmI79bQlUBFDmtOXTvVQ5IFrsVTgFZBflXf1u2 n5RMcQlSJwLDUW2Zoc0bh4OcHejPzcFReuG6IUci+/MKNR+otD3oKKTPTYvIWVmUWEvg b5z8hpfQiKbtStlsYkxgZsnMT7MpM1jaMFIpeyoF4Eqt4zdyQdsGyD3yzDuxQ7S3ptRF tGD9/cQbO4KYvqhHYcIq6qsHVVFGwz/pvmYOlykYuhh1/1jruz8zK5SG1n4IZ8NjyxPv rv5x4H6/3QVZdLxrh4Lnz6UCya1iGL80WMfCx2uX7hUqMWXGJ9jjG+Dqe2RBfpraMJR5 uy2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677594547; 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=oVw5vMuMZUFFaMpO4p5gOvCj1Hyho47Y0PK17bHYiRM=; b=Agt4hnVazviY+3RVWYVagYsS+PJCV6y2ILLIq7ADGeeTaHwKqdr/2HoitWxIcyM2/Z +A2HiFPcHigLuSQuC3jPwXPpgNLUtLNN+rgLqpGMbla3yvvsN0N/m6jdoLcF/ViEm08G /mP60FhPJDO+TT8yCVVaAdF+3mArFFsi2XSPOaiVbxChJN8dth9CVoW3zcrGPg5binmR dvvSWDrgfaTuPeo1uodPEb2q9L3+3dz68OQbpVMcJesGI1kRfZiI+VBwLRxT+hvWcgbB lfP2ousnifMHy5Kc0zWwgzkRn0xD+HHHvDV59NeOPOqMtFYdJn4aSFECH5+T8RgfMO1F tvRw== X-Gm-Message-State: AO0yUKXV8YZVgvaE3FavsEoyCSZWWTuh6+wQJE33TRaeENvcBqwxc/RD xwGhfF+lsMI4dFuVXRPO6fp76M+bDtzIXPLHveM= X-Google-Smtp-Source: AK7set8MmzOVMlsWo1H7/qMJo31QXNbu3JidW77G6c7i7B1hluupGpodph9luqTMOE4S65bzDzFlhw== X-Received: by 2002:a05:6870:46a7:b0:163:7fed:73d5 with SMTP id a39-20020a05687046a700b001637fed73d5mr1755071oap.45.1677594547049; Tue, 28 Feb 2023 06:29:07 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c3:d849:1526:5720:5f77:6ab6? ([2804:1b3:a7c3:d849:1526:5720:5f77:6ab6]) by smtp.gmail.com with ESMTPSA id dv4-20020a056870d88400b0016e9308e17bsm3290271oab.52.2023.02.28.06.29.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Feb 2023 06:29:06 -0800 (PST) Message-ID: Date: Tue, 28 Feb 2023 11:29:03 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v3] i386: Use pthread_barrier for synchronization on tst-bz21269 Content-Language: en-US To: DJ Delorie Cc: libc-alpha@sourceware.org References: From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,NICE_REPLY_A,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 27/02/23 19:21, DJ Delorie wrote: > Adhemerval Zanella writes: > >> static void * >> threadproc (void *ctx) >> { >> - while (1) >> + for (int i = 0; i < NITER; i++) > > Ok. > >> - futex ((int *) &ftx, FUTEX_WAIT, 1, NULL, NULL, 0); >> - while (atomic_load (&ftx) != 2) >> - { >> - if (atomic_load (&ftx) >= 3) >> - return NULL; >> - } >> + xpthread_barrier_wait (&barrier); > > - parent up to this point has set up the LDT > block 1 - thread waits for parent; > >> /* clear LDT entry 0. */ >> const struct user_desc desc = { 0 }; >> xmodify_ldt (1, &desc, sizeof (desc)); >> >> - /* If ftx == 2, set it to zero, If ftx == 100, quit. */ >> - if (atomic_fetch_add (&ftx, -2) != 2) >> - return NULL; >> + /* Wait for 'ss' set in main thread. */ >> + xpthread_barrier_wait (&barrier); > > block 2 - child sets ldt, parent does nothing > > - post, parent sets SS. This still isn't doing what the original test > case was doing. > > The original code did this: > > > Parent changes LDT and sets SS > - force a task switch, which should segfault > - sigaction's handler either works, or fails <-- important part > - child resets LDT > > Do you have a version of libc newer than the patch in BZ#21269 that you > can test the modified test against, to make sure it still detects the > failing case? What I did was to actually revert the original fix and check if the test in fact trigger the issue: diff --git a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c index 0665b41bbc..b2454d8d55 100644 --- a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c +++ b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c @@ -33,7 +33,7 @@ extern void restore (void) asm ("__restore") attribute_hidden; ? &restore_rt : &restore); \ } \ else \ - (kact)->sa_restorer = NULL; \ + (kact)->sa_restorer = (void*)0xdeadbeef; \ }) #define RESET_SA_RESTORER(act, kact) \ And it does not, because as you pointed out the barrier are not fully correct. So I circle back and I think the v2 is actually correctly, using a bogus sa_restore does trigger a failure and the test succeeds with current code. > > Thinking about it, I suspect this change shouldn't be done: > >> - TEST_VERIFY_EXIT (sigaction (sig, &sa, 0) == 0); >> + xsigaction (sig, &sa, 0); > > Although they do the same things, since it's sigaction we're actually > testing here, hiding it in an xfunction isn't appropriate. > Alright.