From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3437A3858C5F; Mon, 18 Mar 2024 18:45:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3437A3858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710787526; bh=tNnSlDtr0eWpv/UEFdA3EN8R+KJvofLdzgVOE6K8TAQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bW3DlEi7pIDvDkWvyCzXVbkRTBNLuZ3UroH/dKbnXZfdEaA3wJpliaDiKWt/e+uol nwOu1SP/5SDfJYmXbZiJRBVGcpGzzVIYyzmMmvuxyRlvbjfPPQayX4WrquA3H40kgE OK55u2nDX0Rt8i8PgM5KIXIz5a1T3kquVgQfHo9Q= From: "thiago.bauermann at linaro dot org" To: gdb-prs@sourceware.org Subject: [Bug testsuite/31312] attach-many-short-lived-threads gives inconsistent results Date: Mon, 18 Mar 2024 18:45:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: testsuite X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thiago.bauermann at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: cel at linux dot ibm.com X-Bugzilla-Target-Milestone: 15.1 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.isobsolete attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31312 Thiago Jung Bauermann changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #15405|0 |1 is obsolete| | --- Comment #19 from Thiago Jung Bauermann --- Created attachment 15415 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15415&action=3Ded= it Proposed fix. Needs to be cleaned up. I investigated this problem some more, and I see three separate issues revealed by attach-many-short-lived-threads.exp: 1. The issue I mentioned in comment #17 (which I have since confirmed is what is going on), where the linux_proc_attach_tgid_threads () never ends when there are zombie threads present in the inferior. Since attach-many-short-lived-threads.c constantly creates and finishes joinable threads, the chance of having zombie threads is high. From looking at the gdb.log files Carl provided, I believe he is seeing the same problem. The solution is to make GDB remember when it has already visited the /proc directory of a given LWP, and skip it in the following iterations. I implemented the attached patch to do that, and now I don't observe GDB hanging anymore in the aarch64-linux server in which I used to easily reproduce this problem. If Carl could test it on POWER10, it would be helpful. I'll clean up the code and post it on the mailing list. 2. Behaviour 2 which I described in comment #12. I'll repeat it here for completeness: (gdb) attach 2039552 Attaching to process 2039552 Cannot attach to lwp 2689792: Operation not permitted (1), process 2689792 is already traced by process 2039527 PID 2039552 is the testcase inferior, and 2039527 is GDB. GDB didn't report any success in attaching to the process. This is very rarely observed on my test system. I saw it only 3 times in thousands of testcase runs. I wasn't able to investigate it yet. I'll open a separate bugzilla about this. 3. This one isn't a bug, but an issue that arises from the way attach-many-short-lived-threads.c behaves: since it's constantly creating new threads it's impossible for GDB to know when it has attached to all of them so that it can finish the loop in linux_proc_attach_tgid_threads (). Because of this, even with the fix for issue #1 applied, the testcase fails once in a while =E2=80=94 I lef= t the test running in a loop overnight and it failed after about 2500 iterations. The only way I can see to improve GDB's behaviour is to increase the number of iterations of the loop that checks for new threads. I suspect that the ability of the inferior to create new threads is proportional to the number of CPUs present in the system (my test machine has 160 cores), so I will propose a patch that makes the number of iterations proportinal to the number of CPUs. --=20 You are receiving this mail because: You are on the CC list for the bug.=