From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by sourceware.org (Postfix) with ESMTPS id 1D3A63858D35 for ; Thu, 3 Feb 2022 18:04:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D3A63858D35 Received: by mail-qt1-x82d.google.com with SMTP id r14so3498466qtt.5 for ; Thu, 03 Feb 2022 10:04:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=+ceBghPdPsMpHBL2A0Pg1A6pBWD+34NWK4iDr+LT94o=; b=fQLuUrEHRUBawMnINFBSp3QeQ40b2FDjNP1eJjQAKLKur1mxtC/UNzCgvUPzjUPmbg fBrpX2uuPc3OjoPJ+9mi/3+eX9McILwRKxEspY7gYYQJRhE2NBWBijSc2iIGVUR8+eto cEMeeJVk50CfzAVy0s4G7gfh5CEBx+MZJk1QS0GrsSf3H+xyGWqeamdDxeV95nYm8Jdx zEc5Tc9EBB+TtpQtAZt0hs26Eg8tQl1qzHiq2O8/soJhmkQHx0d+K4jhd2YeUfqqGXxV TRVmMPPyRPAdUiwdIlZcaURatrlqVZMM3YfbxvLTqMkZ7ZXJMD8hGWSvpSwjL4q+F/VH KIPQ== X-Gm-Message-State: AOAM532aXqmyYOzUAiFnirG3if0uHVGdf7OxFv4dP+7xoIngADCg0PSg FHdPT5pTXc+Ej1+8/0Mf6hbPA2ssVG4I3EXz X-Google-Smtp-Source: ABdhPJy3sBqgCxylvj8gzZJUiWYuOoOIm0OxTmi+8j+Ypb0B+TnFoN7hvTgyFxpkMgtl5EdUeecmaQ== X-Received: by 2002:a05:622a:446:: with SMTP id o6mr20628631qtx.504.1643911475591; Thu, 03 Feb 2022 10:04:35 -0800 (PST) Received: from smtpclient.apple (bras-base-toroon63x9w-grc-25-174-95-135-52.dsl.bell.ca. [174.95.135.52]) by smtp.gmail.com with ESMTPSA id e17sm6401048qte.94.2022.02.03.10.04.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Feb 2022 10:04:35 -0800 (PST) From: Siwei He Message-Id: <7E84D937-3772-4E0A-9726-8B06CED4FC94@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601" Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: [PATCH] gdb: A potential fix for PR-24069 Date: Thu, 3 Feb 2022 13:04:33 -0500 In-Reply-To: <4bf807c4-d78f-05a4-6cf5-4fa283bc7c1d@simark.ca> Cc: Siwei He <1726110778@qq.com>, gdb-patches@sourceware.org To: Simon Marchi References: <20220202193116.79655-1-siweihe.eng@gmail.com> <4bf807c4-d78f-05a4-6cf5-4fa283bc7c1d@simark.ca> X-Mailer: Apple Mail (2.3693.60.0.1.1) X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 18:04:39 -0000 --Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Simon, I have turned the debug message switch on both on my patched version vs. = The unpatched version. The results are attached in the email. --Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601 Content-Disposition: attachment; filename=patched.txt Content-Type: text/plain; x-unix-mode=0644; name="patched.txt" Content-Transfer-Encoding: quoted-printable [21378 inferior]: GDB task: 0x203, pid: 21378 = = =20 GNU gdb (GDB) 12.0.50.20220202-git = = =20 Copyright (C) 2022 Free Software Foundation, Inc. = = =20 License GPLv3+: GNU GPL version 3 or later = = =20 This is free software: you are free to change and redistribute it. = = =20 There is NO WARRANTY, to the extent permitted by law. = = =20 Type "show copying" and "show warranty" for details. = = =20 This GDB was configured as "x86_64-apple-darwin21.3.0". = = =20 Type "show configuration" for configuration details. = = =20 For bug reporting instructions, please see: = = =20 . = = =20 Find the GDB manual and other documentation resources online at: = = =20 . = = =20 = = =20 For help, type "help". = = =20 Type "apropos word" to search for commands related to "word"... = = =20 Reading symbols from /Users/siweihe/Developer/ECE496/a.out... = = =20 Reading symbols from = /Users/siweihe/Developer/ECE496/a.out.dSYM/Contents/Resources/DWARF/a.out.= .. =20 (gdb) b main = = =20 Breakpoint 1 at 0x100003f9d: file test.c, line 2. = = =20 (gdb) r = = =20 Starting program: /Users/siweihe/Developer/ECE496/a.out = = =20 [21378 inferior]: inferior task: 0x1103, pid: 21449 = = =20 [21378 inferior]: new_ix:0/1, old_ix:0/0, new_id:0x1503 old_id:0x0 = = =20 [New Thread 0x1503 of process 21449] = = =20 [[2137821449 inferior]: inferior]: darwin_wait: waiting for a message = ptid=3D21449.0.0ptrace ( = =20 PT_TRACE_ME, 0, 0x0, 0): 0 (no error) = = =20 [21449 inferior]: ptrace (PT_SIGEXC, 0, 0x0, 0): 0 (no error) = = =20 message header: = = =20 bits: 0x1200 = = =20 size: 0x24 = = =20 remote-port: 0x0 = = =20 local-port: 0xe03 = = =20 reserved: 0x0 = = =20 id: 0x48 = = =20 data: 00000000 00000001 00001103 = = =20 [21378 inferior]: darwin_wait: pid 1407 received status=3D0x4427d9a = = =20 [21378 inferior]: darwin_wait: pid 21449 received WIFSTOPPED message header: = = =20 bits: 0x80001112 = = =20 size: 0x4c = = =20 remote-port: 0x2903 = = =20 local-port: 0x1003 = = =20 reserved: 0x0 = = =20 id: 0x961 = = =20 body: descriptor_count=3D2 = = =20 descr 0: type=3D0 (port) name=3D0x1603, dispo=3D17 descr 1: type=3D0 (port) name=3D0x2803, dispo=3D17 NDR: mig=3D00 if=3D00 encod=3D00 int=3D01 char=3D00 float=3D00 data: 00000005 00000002 00010003 00000005 [21378 inferior]: new_ix:0/1, old_ix:0/1, new_id:0x1603 old_id:0x1503 [21378 inferior]: new_ix:0/1, old_ix:1/1, new_id:0x1603 old_id:0x0 [New Thread 0x1603 of process 21449] [21378 inferior]: darwin_wait: thread=3D0x1603, got EXC_SOFTWARE [21378 inferior]: (signal 5: SIGTRAP) [21378 inferior]: darwin_xfer_partial(0x0000000000000000, 4096, = rbuf=3D0x7fdcac813c00, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_xfer_partial(0x0000000000000000, 8, = rbuf=3D0x7ff7bc016288, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_xfer_partial(0x00000001000881b8, 24, = rbuf=3D0x7ff7bc0161f0, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x00000001000881b8, len=3D24) warning: unhandled dyld version (17) [21378 inferior]: darwin_xfer_partial(0x00000001000881b8, 24, = rbuf=3D0x7ff7bc0160f0, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x00000001000881b8, len=3D24) [21378 inferior]: darwin_xfer_partial(0x0000000100003f80, 64, = rbuf=3D0x60000270151c, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f80, len=3D64) [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, = rbuf=3D0x7ff7bc015dd0, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, = rbuf=3D0x7ff7bc015d40, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=3D0x0, = wbuf=3D0x104508880) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) [21378 inferior]: darwin_read_write_inferior: mach_vm_region_recurse = addr=3D0x0000000100003000, start=3D0x0000000100000000, = len=3D0x0000000000004000 [21378 inferior]: darwin_resume: ptid=3D21449.0.0, step=3D0, signal=3D0 [21378 inferior]: darwin_resume_thread: state=3D2, thread=3D0x1603, = step=3D0 nsignal=3D0 [21378 inferior]: ptrace (PT_THUPDATE, 21449, 0x1603, 0): 0 (no error) [21378 inferior]: darwin_set_sstep (thread=3D0x1603, enable=3D0) [21378 inferior]: darwin_wait: waiting for a message ptid=3D-1.0.0 message header: bits: 0x80001112 size: 0x4c remote-port: 0x150b local-port: 0x1003 reserved: 0x0 id: 0x961 body: descriptor_count=3D2 descr 0: type=3D0 (port) name=3D0x1603, dispo=3D17 descr 1: type=3D0 (port) name=3D0x2803, dispo=3D17 NDR: mig=3D00 if=3D00 encod=3D00 int=3D01 char=3D00 float=3D00 data: 00000006 00000002 00000002 00000000 [21378 inferior]: darwin_wait: thread=3D0x1603, got EXC_BREAKPOINT [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=3D0x0, = wbuf=3D0x7fdcac17c16c) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) [21378 inferior]: darwin_read_write_inferior: mach_vm_region_recurse = addr=3D0x0000000100003000, start=3D0x0000000100003000, = len=3D0x0000000000001000 Thread 2 hit Breakpoint 1, [21378 inferior]: = darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=3D0x7ff7bc015df7, = wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, = rbuf=3D0x7ff7bc015df7, wbuf=3D0x0) pid=3D21449 [21378 inferior]: darwin_read_write_inferior(task=3D0x2803, = 0x0000000100003f9d, len=3D1) main () at test.c:2 2 int a =3D 0;= --Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601 Content-Disposition: attachment; filename=unpatched.txt Content-Type: text/plain; x-unix-mode=0644; name="unpatched.txt" Content-Transfer-Encoding: quoted-printable [40645 inferior]: GDB task: 0x203, pid: 40645 GNU gdb (GDB) 12.0.50.20220202-git Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later = This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-apple-darwin21.3.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /Users/siweihe/Developer/ECE496/a.out... Reading symbols from = /Users/siweihe/Developer/ECE496/a.out.dSYM/Contents/Resources/DWARF/a.out.= .. (gdb) b main Breakpoint 1 at 0x100003f9d: file test.c, line 2. (gdb) r Starting program: /Users/siweihe/Developer/ECE496/a.out=20 [40645 inferior]: inferior task: 0x1103, pid: 40718 [40645 inferior]: new_ix:0/1, old_ix:0/0, new_id:0x1503 old_id:0x0 [New Thread 0x1503 of process 40718] [40645 inferior]: darwin_wait: waiting for a message ptid=3D40718.0.0 [40718 inferior]: ptrace (PT_TRACE_ME, 0, 0x0, 0): 0 (no error) [40718 inferior]: ptrace (PT_SIGEXC, 0, 0x0, 0): 0 (no error) message header: bits: 0x1200 size: 0x24 remote-port: 0x0 local-port: 0xe03 reserved: 0x0 id: 0x48 data: 00000000 00000001 00001103 [46836 inferior]: WIFSTOPPED [40645 inferior]: darwin_wait: pid=3D40718 exit, status=3D0x57f= --Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 As pointed out by Domq half a year ago, it seems like the gdb doesn=E2=80=99= t have to call another wait4(). The patch can fix the deadlock problem. = I am having limited time dig deeper into the root cause of the bug, but = I will try poking around and see what I can find out. Best, Louis > On Feb 2, 2022, at 4:26 PM, Simon Marchi wrote: >=20 > On 2022-02-02 4:01 p.m., Siwei He via Gdb-patches wrote: >> Hi Simon, >>=20 >> You are absolutely right. I am new to the community and I noticed = that I >> didn't merge two of my commits together in the patch file. I have = already >> merged them and included in the attachment in this email. I also = uploaded >> it to the bug report: >> https://sourceware.org/bugzilla/attachment.cgi?id=3D13953 >>=20 >> Best, >> Louis > Thanks, that makes more sense. >=20 > I'd like if we could at least get some understanding of what's = happening > here and get an explanation in the commit message, otherwise it feels > like just feels like throwing random things on the wall and seeing = what > sticks. >=20 > Could you please provide the output of a GDB session running a trivial > program, with both "set debug infrun 1" and "set debug darwin 12" (not = a > typo, the last one is really "12")? Then we can have an idea of the > sequence of events. If you can get one where things work and one = where > things don't work, it would be even better, since it would allow us to > compare. >=20 > I'm trying to understand what the code you change does. It is in a > scope that starts like this: >=20 > else if (hdr->msgh_id =3D=3D 0x48) > { > /* MACH_NOTIFY_DEAD_NAME: notification for exit. */ >=20 > What does that mean, does it mean we have received some message / > notification to tell us the inferior has exited? So what does it mean > to then receive a WIFSTOPPED wait status for that pid? >=20 > I think it would be useful do add a debug print just after the wait4 > call above, to print (in hexadecimal) the wstatus value returned by > wait4. >=20 > Simon --Apple-Mail=_B390C394-864E-4B7A-88F5-916B80C37601--