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.133.124]) by sourceware.org (Postfix) with ESMTPS id B84A33858435 for ; Sat, 6 Apr 2024 17:40:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B84A33858435 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B84A33858435 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712425246; cv=none; b=UHOZ4dZ/LmHvNBgoWTZ7AlMHF/GwB7a5FXQOrcImvREsrJZeMsbWZyZBZZw0DQbGcBJiD58GTC6vc8Zb77olNnyMzw14PLtpMQuAxXOhwvtzpQY6bdQROHHDXTFWp4IYJGIuQ4wS5fAbyIBs73X6g864tNC0zjB5mwZaIa9NHeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712425246; c=relaxed/simple; bh=JVxEOJ3nn0ZLMpzYTYXEfHmL2QYSnOWqg7hcewMxHAo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XG5HHgiaS0JO+EyVdsDEbcLij8u5sBxMQ8p2rBQMCpFLWjykJypyjjD9gbAPUb6P2e5jcB6wnxfv0Q38kJSaCYonohVZdJxGhejv0cmPcXd1DMIS7JfKehXNIzPITFUxS2E3LMcLTXkCtVMmXEJMn+UUfPAwjbCC2ndJNEZzFdY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712425244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RWs9+TN18sehuJPONSLIqFiKMmrpC9SREbaBC46A3bo=; b=Rb6y7c6nH+EYIHE5Tp8k1RIoWu3WfB2W8rP/X1Vps3qqdKFdRszdkxkZo6mx28TMh9wahm g8KZspeO/sGLhlTcl2H4eqqKj6obYkpzxyiU5gjuT/Bm/V8FjUhuwBxU96iinJ6OeXbuaQ sYjsxjlliIY2hIeaGUqIAl0k6l3BWT0= 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-442-u4oqBIABPGSW2QLFx3Akpg-1; Sat, 06 Apr 2024 13:40:43 -0400 X-MC-Unique: u4oqBIABPGSW2QLFx3Akpg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a51b97efbb8so61790866b.1 for ; Sat, 06 Apr 2024 10:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712425242; x=1713030042; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RWs9+TN18sehuJPONSLIqFiKMmrpC9SREbaBC46A3bo=; b=bg1fkz/DK+FUZ/JjBIXRJzPGP8Yh+oaZNcSjZQo4CX5ImZlRuNR4SG1SO6CPZZFkLb dNS5V5ACc7IRW/pk6i1IiZlAkwiMKjOAPFA8r4lmtwX3W+vBJJoNQKWwF6qIIivxT/Jx nAIgzi7h+EWScl6718lmoZbmwLEOb5oLddf8lU/GBchKb8geia0vO5QOb7mDfbKVnTyR IsAqwU5uC1Ipb7Aotn2TMICb5zDb2aYyORuQPzY+E7NCNJzES2Au7cjXPx5kUK7LKC3T EPngj2ykvmIaBuma0BWbem46/YZGy2RMMRhevbBC8o7ZtUqtPu0/t2vegfuoTUcagS6F CeaQ== X-Forwarded-Encrypted: i=1; AJvYcCXbuJLJvsQnMS7LSvipQgigbj0TA/H/Gpzo/qeHt5gPCN2UYnOV1ZeDBNsVEJ8KtPEfR/Iqai3lPQCHnrVVHl2gX3c2d1x/nnbilg== X-Gm-Message-State: AOJu0Yw3uS1Prqv36WlavxSCXWYqf9NFcPzPMTLL3X1KjcCQ3nHADv9f bG0DFHiG2oMdgdLwqbeBbcRDF8SnM0595DfGmS1IJc8sdG8sYye5NZDfUPkkZ01wvyWzcdYAOT4 4+fRzlhBJ7HR8Av0NlNPm/Z3ODKATWjKrug9tnJbhfI6H1V5nFgyMu7sjn9g= X-Received: by 2002:a17:906:bc46:b0:a51:9e23:dc44 with SMTP id s6-20020a170906bc4600b00a519e23dc44mr4227189ejv.31.1712425241781; Sat, 06 Apr 2024 10:40:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVynXXyeR3IRyIIoGimBZ4CHCrdgomwYNv2PjR6flQcP/bfaApmBVnGzzHCtjvCpsv1MSyUQ== X-Received: by 2002:a17:906:bc46:b0:a51:9e23:dc44 with SMTP id s6-20020a170906bc4600b00a519e23dc44mr4227175ejv.31.1712425241201; Sat, 06 Apr 2024 10:40:41 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id an2-20020a17090656c200b00a51b00b5236sm1402276ejc.120.2024.04.06.10.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 10:40:40 -0700 (PDT) From: Andrew Burgess To: Bernd Edlinger , "gdb-patches@sourceware.org" , Thiago Jung Bauermann Subject: Re: [PATCH v2] Fix sporadic XFAILs in gdb.threads/attach-many-short-lived-threads.exp In-Reply-To: References: Date: Sat, 06 Apr 2024 18:40:39 +0100 Message-ID: <87cyr22xuw.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Bernd Edlinger writes: Thanks for looking into these failures. > 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 the read has the errno=ESRCH, use that as an indication that the > thread has exited between fopen and reading of the status file. I assume this would be the commit message for this change? This text seems to be out of date given the changes in V2 and probably needs updating. Thanks, Andrew > --- > 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. > > 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); > } > -- > 2.39.2