This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

tui/2242: Race condition on run


>Number:         2242
>Category:       tui
>Synopsis:       Race condition on run
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 27 13:38:01 BST 2007
>Closed-Date:
>Last-Modified:
>Originator:     Joshua Neuheisel
>Release:        GNU gdb 6.6.50.20070326-cvs
>Organization:
>Environment:
Linux 2.6.12-1-686-smp #1 SMP Tue Sep 27 13:10:31 JST 2005 i686 GNU/Linux
>Description:
Running gdbtui incurs a fatal race condition between ptrace calls on the parent and child.
>How-To-Repeat:
1. Create a C source file sample.c with the following line:
int main (void) { return 42; }

2. Compile the source as follows:
gcc -g -o sample sample.c

3. Run "gdbtui ./sample".  The output will be:
Couldn't get registers: No such process.
>Fix:
After the fork in fork-inferior.c, the child will call ptrace(TRACEME) in "(*traceme_fun) ()".  This will cause the child to sleep.  The parent (gdbtui) should wait for the child to go to sleep, the do a ptrace to begin debugging.  Instead, the parent calls starup_inferior which eventually calls tui_registers_changed_hook which eventually calls fetch_regs.  This last function calls ptrace(GETREGS) which fails whenever the child has not yet called its ptrace.

A possible fix would be to wait for the child to call its ptrace before calling "fetch_regs", or the "tui_registers_changed_hook" could handle the exception thrown by "fetch_regs" and ignore it.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]