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 A62E83857B9B for ; Mon, 14 Aug 2023 20:58:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A62E83857B9B 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=1692046708; 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: content-transfer-encoding:content-transfer-encoding; bh=6h4xZOx9y6OSOehDxKHgd+DxoLkcdXHkCQ+EWOSki4k=; b=fTc1cVS+xVNwbC3A6tUEl7IGlizgDWsnrJjFT8Y1LpjCGcf5cX0OpuSJmtp6UYP5neHdhe GQZCk9WcSB30ixP2aPMOTq1nB3tS4MPvWkEXk5IpxAofm6l8pme3kjH7dap+4YlR/RLwvq JpOAFHH8+7BJXEXT4kZoQWPFpT1YPUE= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-MQh9W9gRPICiEHm6RJrvwA-1; Mon, 14 Aug 2023 16:58:27 -0400 X-MC-Unique: MQh9W9gRPICiEHm6RJrvwA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-99beea69484so278753866b.0 for ; Mon, 14 Aug 2023 13:58:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692046706; x=1692651506; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6h4xZOx9y6OSOehDxKHgd+DxoLkcdXHkCQ+EWOSki4k=; b=E8B313a+D1E2mPRi8Cm4ogDyOn8Fgt6+F2J8FtSeY1ccibmnhAu8jgT1bX6aXPlLIv ABO2yGhPV0xGU7lRkf5zABmU8KF/lJt8P8JVjZerY6D9e1RHzAm4CXybNPkHKaTNmakD EtDzd0KwIlGH2PD3Rl2NMqOo3LyfO9WMcK7BVPjKZ3KJa/3+BNWhjMXXDHEaB66k1U6g 2BSKRukoR9dEcZS+yv31yGYJDRS3czDI6Az2Dco3x9kQZjgn5VCK6wGAvg72M+cq7Nyr iVdRkSF/toZmnMNTieJb4beT3DWhX2xu7fVe0A2il298RpaICg/p/fCRotqxEl0ogMca sLpA== X-Gm-Message-State: AOJu0YwEyVv0NNAhI8XdwYPsggVcxEHPkwmtnadWReYQiWgpgSzqAufu /tYPPjGACvO/yR9eloJJkdf3y1lY9KL108u1Eyfph3jm8toNLdkC7mJ5VLW/EfKkNnxUmQRPsHd sUMBJi6Pxk1vQ1ikKCEl2uuyuy9KcDlkx7t2cTqEJPcREeknmF5dIq/c8qcO2ElSTVs8BR/z5/z L+uMgw9w== X-Received: by 2002:a17:906:53d3:b0:99b:627b:e96d with SMTP id p19-20020a17090653d300b0099b627be96dmr9046550ejo.44.1692046705843; Mon, 14 Aug 2023 13:58:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVCsafijSC11y/o1leYNo2Abs7WQU82lS5mUU9JOfzymTMVS9bZmdBACnCQLcn9BAGagw3jw== X-Received: by 2002:a17:906:53d3:b0:99b:627b:e96d with SMTP id p19-20020a17090653d300b0099b627be96dmr9046537ejo.44.1692046705547; Mon, 14 Aug 2023 13:58:25 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id k9-20020a1709065fc900b0099329b3ab67sm6113194ejv.71.2023.08.14.13.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 13:58:25 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Simon Farre , Andrew Burgess Subject: [PATCH] gdb/testsuite: fix race condition in gdb.python/py-thread-exited.exp Date: Mon, 14 Aug 2023 21:58:23 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: I ran into a test failure on gdb.python/py-thread-exited.c. The test creates two threads and then catches the thread exits in Python. The test expects the threads to exit in a specific order. As the test is currently written, it is _likely_, but not guaranteed, that the threads will exit in the same order they are created, which is what the test expects. When running on a loaded system I ran into a case where the threads exited in the reverse creation order, which caused the test to fail. I could fix this by having the .exp file not care about the thread order, or by changing the C file to force the order. I chose the later, and added a pthread_barrier_t to ensure the threads exit in the correct order. There should be no change in what is tested after this commit. --- gdb/testsuite/gdb.python/py-thread-exited.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-thread-exited.c b/gdb/testsuite/gdb.python/py-thread-exited.c index d62133ba59e..4df6b587935 100644 --- a/gdb/testsuite/gdb.python/py-thread-exited.c +++ b/gdb/testsuite/gdb.python/py-thread-exited.c @@ -24,14 +24,25 @@ pthread_t thread3_id; void* do_thread (void* d) { + if (d != NULL) + { + pthread_barrier_t *barrier = (pthread_barrier_t *) d; + pthread_barrier_wait (barrier); + } + return NULL; /* In thread */ } int main (void) { + /* We want the threads to exit in a known order. Use a barrier to ensure + the second thread doesn't exit until the first has been joined. */ + pthread_barrier_t barrier; + pthread_barrier_init (&barrier, NULL, 2); pthread_create (&thread2_id, NULL, do_thread, NULL); - pthread_create (&thread3_id, NULL, do_thread, NULL); + pthread_create (&thread3_id, NULL, do_thread, &barrier); pthread_join (thread2_id, NULL); + pthread_barrier_wait (&barrier); pthread_join (thread3_id, NULL); return 12; /* Done */ } base-commit: 86dfe011797b3e442622d427e9abd1e0f70f3a62 -- 2.25.4