• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision1584354913285389063622a39f845851f332eb9a (tree)
Time2018-08-03 06:08:45
AuthorXavier Roirand <roirand@adac...>
CommiterTom Tromey

Log Message

Fix kill issue leading to zombie process on MacOS Sierra

Starting with MacOS version Sierra, the gdb kill command
seems to work but inferior remains as zombie on the host.
Notice that, as zombie process, the inferior is not killable
by the user, nor by root.

The kill signal gdb sent to the inferior is not handled
in gdb as a signal sent by gdb thus no reply is made and
the process remains (since MacOS does not "release" the
inferior because no reply have been made to the signal
message).

This patch fixes this problem.

gdb/ChangeLog
2018-08-02 Xavier Roirand <roirand@adacore.com>

PR gdb/22629:

        • darwin-nat.c (darwin_kill_inferior): Fix handling of
          kill inferior.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
1+2018-08-02 Xavier Roirand <roirand@adacore.com>
2+
3+ PR gdb/22629:
4+ * darwin-nat.c (darwin_kill_inferior): Fix handling of
5+ kill inferior.
6+
17 2018-08-02 Tom Tromey <tom@tromey.com>
28
39 * darwin-nat.c (find_inferior_task_it, darwin_find_thread)
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1549,6 +1549,24 @@ darwin_nat_target::kill ()
15491549
15501550 if (res == 0)
15511551 {
1552+ /* On MacOS version Sierra, the darwin_restore_exception_ports call
1553+ does not work as expected.
1554+ When the kill function is called, the SIGKILL signal is received
1555+ by gdb whereas it should have been received by the kernel since
1556+ the exception ports have been restored.
1557+ This behavior is not the expected one thus gdb does not reply to
1558+ the received SIGKILL message. This situation leads to a "busy"
1559+ resource from the kernel point of view and the inferior is never
1560+ released, causing it to remain as a zombie process, even after
1561+ GDB exits.
1562+ To work around this, we mark all the threads of the inferior as
1563+ signaled thus darwin_decode_message function knows that the kill
1564+ signal was sent by gdb and will take the appropriate action
1565+ (cancel signal and reply to the signal message). */
1566+ darwin_inferior *priv = get_darwin_inferior (inf);
1567+ for (darwin_thread_t *thread : priv->threads)
1568+ thread->signaled = 1;
1569+
15521570 darwin_resume_inferior (inf);
15531571
15541572 ptid = darwin_wait (inferior_ptid, &wstatus);