From patchwork Sun Apr 7 08:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 88140 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D2D93858C39 for ; Sun, 7 Apr 2024 08:41:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01olkn2055.outbound.protection.outlook.com [40.92.66.55]) by sourceware.org (Postfix) with ESMTPS id 6DFC23858D20 for ; Sun, 7 Apr 2024 08:40:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DFC23858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6DFC23858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.66.55 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1712479260; cv=pass; b=xhLiU9rpH3lX9Dsr24S5nISvuQenx2ZsBPBgXBxGboKICgI8RI/vEqDMhgWqwNZR2DCNjIHwc1R1WKwCWcSObPUxjbpzV67HdLjwaxcXB1aRRj4C7QDfCuGIxio9xQl6MkDQ7N8mDPhzg+aYRE/F6vJf/y0F2f3FxNX7tt2fTrA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1712479260; c=relaxed/simple; bh=ui2Xkb4atgYCfhPTCDEizb/dABZk7175wK0/8rtoAkw=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=Y8iBY1rHnxDFbG7uONZ4GE7vD1ZV3B9l/kCWV7Dn7ND2twSIFMDg8+s2ofQ6zH6oYnY15eqfjY+XdcUz9+git6rhnrrqv2Jpvw4mjEbDAnESf0LBQGL5vdWOXjeLmQqL9E4ioEad8lgHYVpa2Im97W8W5ZAhW5QTzQXKDtVUu6w= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XTgWMNqpNHkBmjVOKEwQJf4CjlutUvD6yfrrit7q2uWWPADD8qvPU4ALTOlwPIzBsXKuZCFyueOSQqxE4ZhBWJR1Zr+N5SJgFDLfnl8RCD17N8LROx3pUANmnDYkx2wbeEmTtDZ1UzNE519jPxBq7zuZzGDU+id07URPI3eVR/Iq9XxubIMWPLZEJfKJz2l6271zuWA+1BUi3o3xKjUY76to9C9H4/6v7L4KaJajQmoOVcGwnu1eGwo4oOzqpOlZ25H0qvQVmCRquNcqdM2u1j2Y6LFPYXOaOMAFPjb0FOYPQIG/ubnn/ARfcimsKDFqKHGsPAR8xPs9tJaZJNXKgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ID+PvpG6+mOuUG6N2rLJFoTHze95n5aQrsJQpUSHGZE=; b=EMEJaZgUtU1KFzBMJiaJ41cCd/q0mzUM9clnoBwF9e6aM6IpVr8pExju6UhnTGVOw0qsbSKv3M3Igfe5flm4gS6qvQI6wIICych1bTSuwfp4zlrEDPl/yB/Fs6yz5c7MohPse1Z/6SDWgz+xGGJsiII98o0rkH8YF9GyjssGga11HmdmP/+wAV+7xmn9D8xjTiTYIys/Psef3pyPp8B1fE4qATl4OGlmlg+0Zo6TqY3+ljobVdkUw/sAXOjRflxYspb1t132sYl7RIxw0cXaJia+RUGW9hjHMO1xlt+/hQ5LaNHRP7Zf6KeyWSBJziX3cf89Xf7FaTGgypASCVj19A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=HOTMAIL.DE; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ID+PvpG6+mOuUG6N2rLJFoTHze95n5aQrsJQpUSHGZE=; b=GaCOQVLWyz67oLPOFOGxqkOHbCmKBG+otD/ykEPVIzfW8iIhh+khgrSKkSHExZmoDjzl82oU4t6WL/DJsmbNaKOJBPeSUQq73WnMMF9REm6uX7EUNuXva2gmZ/waZMptljBGXEciG9JbA8EyPuHIdB4VJtqH1VkHPQEo7p3c5D7UWIXqlSHyR38YCrCgSvDHXHRtoTa1py6OSLJ1akJNuMyZt3RJBXDXEM3oO46TeRT8Ey51Hrrl8JE62wjEoUbOrMDMTm3zSxsAOFeKcwYiCsahPRBQboZCxojC3Ofjjb76pliDcSg1pe6Re6diuD3ZR/PEI2Fhpsai/tb0PjZ0Tg== Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) by PAXP193MB1248.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:15b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Sun, 7 Apr 2024 08:40:56 +0000 Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::5403:f1ad:efaf:1f71]) by AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::5403:f1ad:efaf:1f71%4]) with mapi id 15.20.7409.042; Sun, 7 Apr 2024 08:40:52 +0000 Message-ID: Date: Sun, 7 Apr 2024 10:42:31 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "gdb-patches@sourceware.org" , Thiago Jung Bauermann , Andrew Burgess From: Bernd Edlinger Subject: [PATCH v3] Fix sporadic XFAILs in gdb.threads/attach-many-short-lived-threads.exp X-TMN: [FhAUJFJLTxcZaEaQmy5SCmBYO3x/lnLWAI2z3ZrYogs4LY8lWq17aLRv08JVX91e] X-ClientProxiedBy: BE1P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:79::11) To AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P193MB1285:EE_|PAXP193MB1248:EE_ X-MS-Office365-Filtering-Correlation-Id: a5c3ff79-0c08-4ba5-3aa9-08dc56de6a01 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yGYsJY5kT6iFwigAHETjyFxpgkvRhO0T67rKhSz5/w4zj9jvLBEZD1AnWE/49z2Hhouywk4jKSiwK1JfZ4mRhy2mrMSejF4Gmy3wi1mHxqhCCqaIodxdggMnu0FzzxYsGuiFwimWHCondoBrCU4JzkMBHGDuxV2JynRIXAR77cgIBZMBWQmZG/cdrOZcCEZcPA5iNpboFwaRtYaBwQaKL5YEPC+PRIqa6KKGDwi8hnRd3pjtsxAsMMShjQjX0jJfNyWG0zTqmFKjIvUaNIw64Q7AO/iZc9uJcY0Skh78SFK0uHhXsmyuTwyjdnBucOFyMr47rMp8xH1fVDmV/g2IqD6J5trqEMaFtkkayVFXYPZWtbPmqM33O1KBXLXXmBbR+noCPenkYjfQdJ4bkMJtgz35hqh7IBHVP0uxkAnqeXy+4zkJDcuQ99ax1g3aMVvxX/c+Dri+ZkRlkAE143Au4YkpcPPc3mwuMBb+40YuBBmEF8kuq3s5CJxjf7tklkj6KttR2JZSDbrCzpJYPQrs6x2xmk7htO8z2AoG1l1tMrgVJ2/l0iGiSr/xeBY9VE4+nl+lXsqiAMoDnlrEQdWvD2cx07B9Bi/VBtWWJfzCC8MXCWFQE6+WG9vAd+hUkdPRWAy0ZTZg9pGRMZ1Jku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aUThkJafxncghbODsnJuSwqW5O3JtI+zDsaljx8hhzAqBY?= =?utf-8?q?f6MFwBRxCSibKlpGL4JpQEY3wHsH/NBbQhxrFXZ5mZZg59o4yVOdew+6JTEzxb8+H?= =?utf-8?q?rhYa5/mFgmK5PjNZ/F+aXS2DtHSZ3nvmjLPOX95cU+s6tAm6IwRXTtCs/oT6FceXl?= =?utf-8?q?nQHHBduRSn5ZTyHFenK9UXXQk3bfcWCzWz3KeuKKjJCUrpm/+kOsDfMz6ErjpsD+I?= =?utf-8?q?gAfMeVNhTFYrCrvaMBBEQP0ZW4lNHu/7x3631Wxfl0Z0huLjM6jvCjvLz+rR7ug5Y?= =?utf-8?q?F/x7W3tFPA+MhuOT9Tu4WzCShhaJws6JhTy53QzzTpRBUFYbJnkRaFTiuiQGEpKUd?= =?utf-8?q?MTXaiXuIKFIHpzTqTxRRAWHXKowX9vSAPMMRXQkVerqk2K7OTxvLTSQptyi8XulI5?= =?utf-8?q?LPG1+bAKVAMy1Ll67RUz6zW6NU0kJf58ScGfDzCU7P4hIvA6Jphkf4KDmSmBnnERe?= =?utf-8?q?9HtdD6qIFQ6nE+87?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-80ceb.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: a5c3ff79-0c08-4ba5-3aa9-08dc56de6a01 X-MS-Exchange-CrossTenant-AuthSource: AS8P193MB1285.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2024 08:40:46.3395 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXP193MB1248 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This is about random test failures like those: XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 6: attach (EPERM) XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 7: attach (EPERM) XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 8: attach (EPERM) XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 9: attach (EPERM) XFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 10: attach (EPERM) The reason for this effect is apparently as follows: There is a race condition when gdb tries to attach a thread but the thread exits at the same time. Normally when that happens the return code of ptrace(PTRACE_ATTACH, x) is EPERM, which could also have other reasons. To detect the true reason, we try to open /proc//status which normally fails in that situation, but it may happen that the fopen succeeds, and the thread disappears while reading the content, then linux_proc_pid_get_state fails to find the "State:" line. Since there is no other possible reason why this can happen, use that as an indication that the thread has most likely exited. --- gdb/nat/linux-procfs.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) v2: from kernel code review, it seems the missing "State:" can only happen if the thread disappeared, so no need to look at errno at all here. v3: update commit message. diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index e2086952ce6..8d46d5bf289 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -157,17 +157,12 @@ linux_proc_pid_is_gone (pid_t pid) enum proc_state state; have_state = linux_proc_pid_get_state (pid, 0, &state); - if (have_state < 0) + if (have_state <= 0) { - /* If we can't open the status file, assume the thread has - disappeared. */ + /* If we can't open the status file or there is no "State:" line, + assume the thread has disappeared. */ return 1; } - else if (have_state == 0) - { - /* No "State:" line, assume thread is alive. */ - return 0; - } else return (state == PROC_STATE_ZOMBIE || state == PROC_STATE_DEAD); }