* Re: [PATCH] gdb: A potential fix for PR-24069
2022-02-02 21:26 ` Simon Marchi
@ 2022-02-03 18:04 ` Siwei He
0 siblings, 0 replies; 5+ messages in thread
From: Siwei He @ 2022-02-03 18:04 UTC (permalink / raw)
To: Simon Marchi; +Cc: Siwei He, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
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.
[-- Attachment #2: patched.txt --]
[-- Type: text/plain, Size: 10804 bytes --]
[21378 inferior]: GDB task: 0x203, pid: 21378
GNU gdb (GDB) 12.0.50.20220202-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
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
[21378 inferior]: inferior task: 0x1103, pid: 21449
[21378 inferior]: new_ix:0/1, old_ix:0/0, new_id:0x1503 old_id:0x0
[New Thread 0x1503 of process 21449]
[[2137821449 inferior]: inferior]: darwin_wait: waiting for a message ptid=21449.0.0ptrace (
PT_TRACE_ME, 0, 0x0, 0): 0 (no error)
[21449 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
[21378 inferior]: darwin_wait: pid 1407 received status=0x4427d9a
[21378 inferior]: darwin_wait: pid 21449 received WIFSTOPPED
message header:
bits: 0x80001112
size: 0x4c
remote-port: 0x2903
local-port: 0x1003
reserved: 0x0
id: 0x961
body: descriptor_count=2
descr 0: type=0 (port) name=0x1603, dispo=17
descr 1: type=0 (port) name=0x2803, dispo=17
NDR: mig=00 if=00 encod=00 int=01 char=00 float=00
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=0x1603, got EXC_SOFTWARE
[21378 inferior]: (signal 5: SIGTRAP)
[21378 inferior]: darwin_xfer_partial(0x0000000000000000, 4096, rbuf=0x7fdcac813c00, wbuf=0x0) pid=21449
[21378 inferior]: darwin_xfer_partial(0x0000000000000000, 8, rbuf=0x7ff7bc016288, wbuf=0x0) pid=21449
[21378 inferior]: darwin_xfer_partial(0x00000001000881b8, 24, rbuf=0x7ff7bc0161f0, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x00000001000881b8, len=24)
warning: unhandled dyld version (17)
[21378 inferior]: darwin_xfer_partial(0x00000001000881b8, 24, rbuf=0x7ff7bc0160f0, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x00000001000881b8, len=24)
[21378 inferior]: darwin_xfer_partial(0x0000000100003f80, 64, rbuf=0x60000270151c, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f80, len=64)
[21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x7ff7bc015dd0, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
[21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x7ff7bc015d40, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
[21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x0, wbuf=0x104508880) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
[21378 inferior]: darwin_read_write_inferior: mach_vm_region_recurse addr=0x0000000100003000, start=0x0000000100000000, len=0x0000000000004000
[21378 inferior]: darwin_resume: ptid=21449.0.0, step=0, signal=0
[21378 inferior]: darwin_resume_thread: state=2, thread=0x1603, step=0 nsignal=0
[21378 inferior]: ptrace (PT_THUPDATE, 21449, 0x1603, 0): 0 (no error)
[21378 inferior]: darwin_set_sstep (thread=0x1603, enable=0)
[21378 inferior]: darwin_wait: waiting for a message ptid=-1.0.0
message header:
bits: 0x80001112
size: 0x4c
remote-port: 0x150b
local-port: 0x1003
reserved: 0x0
id: 0x961
body: descriptor_count=2
descr 0: type=0 (port) name=0x1603, dispo=17
descr 1: type=0 (port) name=0x2803, dispo=17
NDR: mig=00 if=00 encod=00 int=01 char=00 float=00
data: 00000006 00000002 00000002 00000000
[21378 inferior]: darwin_wait: thread=0x1603, got EXC_BREAKPOINT
[21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x0, wbuf=0x7fdcac17c16c) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
[21378 inferior]: darwin_read_write_inferior: mach_vm_region_recurse addr=0x0000000100003000, start=0x0000000100003000, len=0x0000000000001000
Thread 2 hit Breakpoint 1, [21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x7ff7bc015df7, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
[21378 inferior]: darwin_xfer_partial(0x0000000100003f9d, 1, rbuf=0x7ff7bc015df7, wbuf=0x0) pid=21449
[21378 inferior]: darwin_read_write_inferior(task=0x2803, 0x0000000100003f9d, len=1)
main () at test.c:2
2 int a = 0;
[-- Attachment #3: unpatched.txt --]
[-- Type: text/plain, Size: 1688 bytes --]
[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 <http://gnu.org/licenses/gpl.html>
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:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
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
[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=40718.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=40718 exit, status=0x57f
[-- Attachment #4: Type: text/plain, Size: 2042 bytes --]
As pointed out by Domq half a year ago, it seems like the gdb doesn’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 <simark@simark.ca> wrote:
>
> On 2022-02-02 4:01 p.m., Siwei He via Gdb-patches wrote:
>> Hi Simon,
>>
>> 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=13953
>>
>> Best,
>> Louis
> Thanks, that makes more sense.
>
> 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.
>
> 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.
>
> I'm trying to understand what the code you change does. It is in a
> scope that starts like this:
>
> else if (hdr->msgh_id == 0x48)
> {
> /* MACH_NOTIFY_DEAD_NAME: notification for exit. */
>
> 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?
>
> 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.
>
> Simon
^ permalink raw reply [flat|nested] 5+ messages in thread