From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9BFE3858D35; Wed, 21 Jun 2023 21:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9BFE3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687381270; bh=5htluKuROgiusrC/MOlVodC4WIFsoMKbbopJPZAPsHk=; h=From:To:Subject:Date:From; b=JNK3edbDVc3i54TFsoSSIIncfSAS3oVVixZGYqOIUXuzZyVz8sJqiMHhgaX7TCiGy JgtTL5xdejIJpp8KEZ3OkSvEo56tjKu6zugYhVyusFs+PUuERnSl1rPW5nAbTfshzA /jxrWqqBoI2Rn5Or8eZyp0TMZjUmWYyxKKIbns6o= From: "aburgess at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug server/30574] New: hang when using remote target, schedule-multiple, follow-fork-mode child, and stepping over a vfork Date: Wed, 21 Jun 2023 21:01:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: server X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aburgess at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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=3D30574 Bug ID: 30574 Summary: hang when using remote target, schedule-multiple, follow-fork-mode child, and stepping over a vfork Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: server Assignee: unassigned at sourceware dot org Reporter: aburgess at redhat dot com Target Milestone: --- Created attachment 14941 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D14941&action=3Ded= it reproducer for this issue When using a remote target and stepping over a vfork with follow-fork-mode = set to child, and schedule-multiple set to on, GDBServer will hang, which in tu= rn causes GDB to hang. To reproduce the issue, download the atteached remote-vfork-bug.tar.bz2, and then: $ tar -xf remote-vfork-bug.tar.bz2 $ cd remote-vfork-bug/ $ make GDB=3D"/path/to/gdb" ... snip lots of output ... Breakpoint 1, main (argc=3D1, argv=3D0x7fffffffacb8) at test.c:11 11 pid =3D vfork (); /* VFORK */ [Attaching after Thread 2182093.2182093 vfork to child Thread 2182094.2182094] [New inferior 2 (process 2182094)] At which point GDB hangs. The problem appears to be that after the VFORK GDB resumes the vfork-child process, but, due to schedule-multiple being on, this results in GDB sendin= g a ptid of -1 to gdbserver, this means resume everything. I think this bit is fine, this is what happens with e.g. the linux-nat layer within GDB, but in the linux-nat layer when we action the -1 ptid we loop o= ver all threads and resume them, except we spot that one thread is a vfork-pare= nt and specifically skip resuming that thread. In contrast gdbserver doesn't skip the vfork-parent, and instead resumes the vfork-parent. While the vfork-child is running the kernel will hold the vfork parent stop= ped. When the vfork-child execs gdbserver sees the event and tries to stop all resumed threads, as the vfork-parent is resumed gdbserver sends it a SIGSTOP and then waits for the thread to report a stop .... and it is this stop that never arrives, and this is where we seem to hang. Some of the details in the above might be a little off, I've only given thi= s a quick review before filing this bug. --=20 You are receiving this mail because: You are on the CC list for the bug.=