From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6E1143858D32 for ; Mon, 27 Feb 2023 22:21:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E1143858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677536519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=zIfOeWzSS654FoHWHzmrbEoGCfiDTKbVldfTOjmRIf0=; b=UnbjTb9oQ7zVl1fjp/K3cgtut0DnAS4RIRkkqPzAXDkxZ7PbzI2mbjSuLj9G8/aFxcx3jh JeYp1OLiy07OA2e3ibw6fGq+RXrpyOA8he/XaZcdoa8GcWM0qWBKhwol7rNzRa+IoKsEmU UWCdBZBFfhjxrgFHOjp8sYR39SQyEr8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-bBv8gEgVNpie0fSC1Es6Ig-1; Mon, 27 Feb 2023 17:21:55 -0500 X-MC-Unique: bBv8gEgVNpie0fSC1Es6Ig-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81C8738012DC; Mon, 27 Feb 2023 22:21:55 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.8.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DA16492B12; Mon, 27 Feb 2023 22:21:55 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 31RMLsRW1182054; Mon, 27 Feb 2023 17:21:54 -0500 From: DJ Delorie To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3] i386: Use pthread_barrier for synchronization on tst-bz21269 In-Reply-To: <20230224161528.997-1-adhemerval.zanella@linaro.org> Date: Mon, 27 Feb 2023 17:21:54 -0500 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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? 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.