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]

[Bug testsuite/23269] fork-running-state hangs make check


https://sourceware.org/bugzilla/show_bug.cgi?id=23269

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a08ac84b963facb4c4a85c4d5df057d44e2a276d

commit a08ac84b963facb4c4a85c4d5df057d44e2a276d
Author: Tom de Vries <tdevries@suse.de>
Date:   Sun Jun 10 15:21:31 2018 +0200

    [gdb/testsuite] Fix hang in fork-running-state.c

    When I run make check:
    ...
    $ cd build/gdb
    $ make check 2>&1 | tee ../CHECKLOG.gdb
    ...
    I see after ~30m the summary of the test run printed, but make still hangs.

    This seems to be due to some sleeping processes:
    ...
    $ ps  fx | grep fork-run
     6475 ?        S      0:00 gdb.base/fork-running-state/fork-running-state
     6451 ?        S      0:00 gdb.base/fork-running-state/fork-running-state
     6427 ?        S      0:00 gdb.base/fork-running-state/fork-running-state
    ...

    Killing the sleeping processes like this:
    ...
    kill -9 $(ps -A  | grep fork-running-st | awk '{print $1}')
    ...
    allows make to finish.

    If I isolate one debug session from fork-running-state.exp that causes one
of
    these sleeping processes, we get:
    ...
    (gdb) set non-stop on
    (gdb) break main
    Breakpoint 1 at 0x400665: file
src/gdb/testsuite/gdb.base/fork-running-state.c,
    line 52.
    (gdb) run
    Starting program: build/gdb/testsuite/outputs/gdb.base/fork-running-state/
    fork-running-state

    Breakpoint 1, main () at src/gdb/testsuite/gdb.base/fork-running-state.c:52
    52        save_parent = getpid ();
    (gdb) set detach-on-fork on
    (gdb) set follow-fork parent
    (gdb) continue &
    Continuing.
    [Detaching after fork from child process 18797]
    (gdb) info threads
      Id   Target Id         Frame
    * 1    process 18793 "fork-running-st" (running)
    (gdb) set print inferior-events off
    (gdb) kill inferior 1
    ...
    So, AFAIU, the hanging process is the child process that gdb detaches from.

    There's an alarm set in main before the fork, but alarms are not preserved
in
    the fork child:
    ...
    $ man alarm
       ...
    NOTES
           Alarms created by alarm() are preserved across execve(2) and are not
           inherited by children created via fork(2).
    ...
    So, AFAIU, once the parent is killed, there's no alarm to terminate the
child.

    The patch fixes this by moving the setting of the alarm into the
    fork_main/fork_child functions, making sure that an alarm will trigger for
    the child.

    Tested with make check on x86_64.

    2018-06-13  Tom de Vries  <tdevries@suse.de>

        PR testsuite/23269
        * gdb.base/fork-running-state.c (main): Move setting of alarm ...
        (fork_child): ... here, and ...
        (fork_parent): ... here.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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